How to configure static IP addresses in CentOS: servers generally have their own static IP addresses so that they can connect to the LAN. 1. edit the Nic file, modify the Nic configuration vim/etc/sysconfig/network-scripts/ifcfg-eth0 to change the contents of the ifcfg-eth0 to the following: & ensp; & ensp
To configure static IP addresses in CentOS, follow these steps:
Servers generally have their own static IP addresses so that they can be connected to the LAN.
1. edit the Nic file and modify the Nic configuration
vim /etc/sysconfig/network-scripts/ifcfg-eth0
Change the contents of the ifcfg-eth0 to the following:
Eni must have DEVICE = eth0 # The DEVICE alias corresponding to the network adapter must have HWADDR = 00: 07: E9: 05: E8: B4 # the network adapter address, that is, if the mac address is too many then TYPE = Ethernet # indicates that the network TYPE is Ethernet too many then UUID: The UUID of the NIC (which can not be found in the file) when the system starts, it automatically loads eth0 when it starts. when the system starts, it automatically loads eth0 when it comes to running NM_CONTROLLED = yes # whether the device is managed by NetworkManager. when the device is running successfully, it BOOTPROTO = static # set the Nic through different protocols how to obtain the IP address, -static-bootp-dhcp dynamic route protocol 255.255.255.ipaddr = 192.168.118.10 # set the nic ip address 255.255.255.255.255.netmask = 255.255.255.0 # set the Nic mask address 255.255.255.255.255.network = 192.168.118.0 # set the NIC corresponding network address 255.255.255.255.broadcast = 192.168.118.255 # set the BROADCAST address of the network card
2. modify the gateway configuration
vi /etc/sysconfig/network
Change the network content to the following:
Required bandwidth used when NETWORKING = yes # indicates whether the system uses the network (IPV4), which is generally set to yes. Zookeeper without NETWORKING_IPV6 = no # IPV6 Zookeeper without HASTNAME # set the host name, localhost. localhostdomain is the default host name named GATEWAY = 192.168.118.1 # set the GATEWAY and select an unused address.
3. modify DNS
vi /etc/resolv.conf
Change resolv. conf to the following:
Add two available dns servers
4. restart the network service.
service network restart
5. use another terminal to verify that ping is successful
6. the IP address is configured and verified successfully.