During the project, the IP address of the host is changed every time the server is restarted because the company's Lan uses the automatic IP address acquisition method. To solve this problem, the solution is as follows: 1. modify Nic configuration Edit: vi/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE = eth0 # describe the device alias for the NIC, for example, in the ifcfg-eth0 file it is eth0BOOTPROTO = sta
During the project, the IP address of the host is changed every time the server is restarted because the company's Lan uses the automatic IP address acquisition method. To solve this problem, the solution is as follows:
1. modify Nic configuration Edit: vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file
BOOTPROTO = static # set the way for the NIC to obtain the IP address. the possible options are static, dhcp, or bootp, which respectively correspond to the IP address specified by the static state and the IP address obtained through the dhcp protocol, IP addresses obtained through the bootp protocol
BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address
HWADDR = 00: 07: E9: 05: E8: B4 # physical address of the corresponding Nic
IPADDR = 12.168.0.33 # If you set the method for obtaining the IP address from the network adapter to static, This field specifies the IP address of the network adapter.
NETMASK = 255.255.255.0 # network mask corresponding to the network adapter
NETWORK = 192.168.0.0 # NETWORK address of the NIC
2. modify the gateway configuration
Edit: vi/etc/sysconfig/network:
NETWORKING = yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
HOSTNAME = centos (set the host name of the local machine. the host name set here must correspond to the host name set in/etc/hosts)
GATEWAY = 192.168.0.1 (set the IP address of the GATEWAY connected to the local machine .)
The first three items are available by default when I open the editing here, so only GATEWAY is added.
3. modify DNS configuration
Edit: vi/etc/resolv. conf:
Nameserver is the IP address of the DNS server. The first is the first choice, and the second is the backup.
4. restart the network service.
Run the following command:
Service network restart or/etc/init. d/network restart