In the project as a result of the company's local area network automatically obtain IP way, to each server restart host IP will change. In order to solve this problem, I refer to other articles and set up static IP according to their own situation to solve the problem, the processing method is as follows:
1. Modify the network card configuration
Editor: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #描述网卡对应的设备别名, for example, Ifcfg-eth0 in a file that is eth0
Bootproto=static #设置网卡获得ip地址的方式, possible options for STATIC,DHCP or BOOTP, respectively corresponding to statically specified IP address, IP address obtained through DHCP protocol, IP address obtained through BOOTP protocol
broadcast=192.168.0.255 #对应的子网广播地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
ipaddr=12.168.0.33 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the network adapter
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.0.0 #网卡对应的网络地址
2. Modify the Gateway Configuration
EDIT: Vi/etc/sysconfig/network modified as follows:
Networking=yes (Indicates whether the system is using the network, typically set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (sets the host name for this machine, where the host name is set to correspond to the hostname set in/etc/hosts)
gateway=192.168.0.1 (Sets the IP address of the gateway for this computer connection.) )
I'm modifying this here. The top three entries are already by default, so only the gateway is added
3. Modify DNS Configuration
EDIT: vi/etc/resolv.conf modified as follows:
NameServer is the DNS server IP address, the first is preferred, and the second is standby.
4. Restart Network Services
To execute a command:
Or
/etc/init.d/network restart
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.