Home>Article>Operation and Maintenance> How to set ip in centos7
How to configure the IP address in CentOS 7: 1. Edit the network configuration file; 2. Set the IP address and network mask; 3. Set the gateway (optional); 4. Enable network services; 5. Verify IP address.
To configure an IP address in CentOS 7, follow these steps:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.0.20 NETMASK=255.255.255.0
If you need to access through the gateway For other networks, please set up the gateway:
GATEWAY=192.168.0.1
systemctl start network
To verify that the IP address has been configured correctly, run the following command :
ifconfig eth0
You should see the following output:
eth0: flags=4163 mtu 1500 inet 192.168.0.20 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::20c:29ff:fe4f:f2b2 prefixlen 64 scopeid 0x20 ether 00:0c:29:4f:f2:b2 txqueuelen 1000 (Ethernet) RX packets 321 bytes 31134 (30.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 292 bytes 31329 (30.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
whereinet 192.168.0.20
represents the assigned IP address.
The above is the detailed content of How to set ip in centos7. For more information, please follow other related articles on the PHP Chinese website!