Network connection configuration of RHEL/CentOS under VMware

Regarding the network configuration on Linux, I have forgotten it for a while, so I just wrote an article myself to understand it. Although there is already a lot of information on this online. But my blog has always been used for notes. . .

This article focuses on the network configuration method of the RHEL/CentOS series. The configuration file may be
/etc/sysconfig/network-scripts/ifcfg-eth0
The configuration file operated in this article is, the operation of this file requires administrator privileges
/etc/sysconfig/ network-scripts/ifcfg-eno16777736
RHEL/CentOS redefines the naming rules of network configuration files from the 7 series, and those who are interested should understand it by themselves.
This article discusses the configuration of fixed ip. If dhcp automatically generates ip, there is no need to configure it.
We know that there are three ways of VMware network connection, namely

bridge mode
nat mode and host
only mode

. properties, only a few differences in details.
# BOOTPROTO accepts both dhcp and static configurations. dhcp means automatically generating network configuration information, so the following four items do not need to be configured. static means static ip configuration, the default is dhcp
BOOTPROTO=static
# IPADDR means IP address
IPADDR=192.168.137.111
# NETMASK means subnet mask
NETMASK=255.255.255.0
# GATEWAY means subnet mask
GATEWAY=192.168.137.2
# DNS1 means the first DNS server, you can also configure a DNS2
DNS1=192.168.137.2
# ONBOOT means whether to automatically start the network when power on, the default is no
ONBOOT=yes

1. Bridge mode The use of
bridge mode is the same as that of a physical machine The network configuration of the network segment can access the external network.
Let's take a look at the current physical machine network configuration configuration as follows
. Viewing method: Control Panel\All Control Panel Items\Network and Sharing Center - "Change Adapter Settings -" Current Network Adapter (Wireless or Wired) )--"Right-click status-"Details, you can view the following information, which is the IP address of my current physical machine



According to this information, we need to modify and add the RHEL/CentOS configuration information as follows:
BOOTPROTO=static
IPADDR=192.168. 1.109
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1
ONBOOT=yes
Then save and restart the network service, and restart the network service refer to the end of the article.

2. Nat mode
Nat mode shares ip information with the current physical machine and can access the external network. The nat mode uses the virtual network card VMnet8 to interact with the current physical machine, and shares the current physical machine ip address to access the external network. The network settings of the virtual machine need to be consistent with the VMnet8 network segment.
Check the VMnet8 network configuration information as follows, the viewing method refers to the bridge mode, but the network adapter is changed to VMnet8.



Note that you see the red box, the IPv4 WINS server is 192.168.137.2, so the GATEWAY and DNS1 configured in the virtual machine need to point to this address
, so the configuration information is as follows:
BOOTPROTO=static
IPADDR=192.168.137.109
NETMASK=255.255.255.0
GATEWAY=192.168.137.2
DNS1=192.168.137.2
ONBOOT=yes
Then save and restart the network service, and restart the network service refer to the end of the article.


3. Host-
only mode means that only the current physical machine can access the virtual machine, and the virtual machine cannot access the external network or the current physical machine. The host-only mode uses the virtual network card VMnet1 to interact with the current physical machine, and only the current physical machine can access the virtual machine. Of course, other virtual machines on the same network segment can also access each other. The network configuration of the virtual machine needs to be consistent with the network segment of VMnet1.
Check the network configuration information of VMnet1 as follows. The viewing method refers to the bridge mode, but the network adapter is changed to VMnet1.



Notice that the value for the IPv4 WINS server in VMnet1 has become empty. Therefore, GATEWAY and DNS1 in the network configuration of the virtual machine here can only point to the 192.168.75. network segment. Generally I am used to using the IP address of the VMnet1 virtual network card. So the network configuration of the virtual machine can be obtained as follows:
BOOTPROTO=static
IPADDR=192.168.75.109
NETMASK=255.255.255.0
GATEWAY=192.168.75.1
DNS1=192.168.75.1
ONBOOT=yes
Then save and restart the network service, and restart the network service refer to the end of the article.

How to restart network services in RHEL/CentOS:
For RHEL6/CentOS6 series and older, we restart the server with
service network restart
For RHEL7/CentOS7 series, we restart the server
with sytemctl restart network
Of course, 7 series can still use 6 A series of service management methods.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326622887&siteId=291194637