Summary of CentOS method to set static IP
1、 Modify network card configuration
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #Describe the device alias corresponding to the network card, such as ifcfg-It is eth0 in the eth0 file
BOOTPROTO=static #Set the way the network card obtains the IP address. The possible options are static, dhcp or bootp, which correspond to the statically specified ip address, the ip address obtained through the dhcp protocol, and the ip address obtained through the bootp protocol.
BROADCAST=192.168.0.255 #Corresponding subnet broadcast address
HWADDR=00:07:E9:05:E8:B4 #The corresponding physical address of the network card
IPADDR=12.168.0.33 #If the method of setting the network card to obtain the ip address is statically specified, this field specifies the ip address corresponding to the network card
NETMASK=255.255.255.0 #Network mask corresponding to the network card
NETWORK=192.168.0.0 #Network address corresponding to the network card
2、 Modify gateway configuration
vi /etc/sysconfig/network
NETWORKING=yes #(Indicates whether the system uses the network, generally set to yes. If set to no, the network cannot be used, and many system service programs will not start)
HOSTNAME=centos #(Set the host name of the machine, the host name set here must be/etc/Corresponding to the host name set in hosts)
GATEWAY=192.168.0.1 #(Set the IP address of the gateway to which this machine is connected.)
Generally, the last line is added.
3、 Modify DNS configuration
vi /etc/resolv.conf
nameserver # is the DNS server IP address, the first is the first choice, the second is the backup.
4、 Restart network
service network restart
or
/etc/init.d/network restart
Thanks for reading, I hope to help you, thank you for your support to this site!
Recommended Posts