Under Centos ip address configuration

In general, centos ip address command to view

ip addr

ip address

 

To configure ip address,

In the / etc / sysconfig / network-scripts / ifcfg-xxx file

 

1, to obtain dynamic ip (provided that your router has opened DHCP)

Modify the network card configuration file vi / etc / sysconfig / network-scripts / ifcfg-ens32 (last name for the card)

Dynamic IP addresses need to modify two places

(1)bootproto=dhcp

(2)onboot=yes

After the modification restart the network services to systemctl restart network

[root@mini ~]# systemctl restart network
[root@mini ~]# 

Such a dynamic IP address configuration is set up, this time to look at the ip addr can see already acquired an IP address, and the Internet (ping Baidu)

 

2, configure a static IP address

Set a static IP address and dynamic iIP almost as well as to modify the network card configuration file vi / etc / sysconfig / network-scripts / ifcfg-ens32 (last name for the card)

(1)bootproto=static

(2)onboot=yes

(3) add the final few lines, IP address, subnet mask, gateway, dns server

IPADDR=192.168.1.160
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=119.29.29.29
DNS2=8.8.8.8

(4) Network Service Restart

[root@mini ~]# systemctl restart network
[root@mini ~]# 

DNS server with only one I use two free dns server, view the IP address, network test

 

Guess you like

Origin www.cnblogs.com/yjp372928571/p/11430377.html