Linux (Centos6 / 7) to modify the ip address (step & detailed most zero-based)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/qq_41718454/article/details/97896911


The content of the picture is my computer, to be set according to your network

0. View network status

At the command line, type ifconfig (Windows is ipconfig), view the current network status (ip, mask, etc.)
Here Insert Picture Description

1. Check the network gateway

At the command line, enter route -n , see your gateway and remember
Here Insert Picture Description

2. Modify ip

Open with vim / etc / sysconfig / network-scripts / ifcfg-eth0 (eth0 is the name of the NIC, depending on what you configure a network card)

vim /etc/sysconfig/network-scripts/ifcfg-eth0

2.1 Set dynamic ip

BOOTPROTO = dhcp, the other can not fill, dns can write

2.2 set up a static ip

BOOTPROTO = static, other required
Here Insert Picture Description

3. Restart network

At the command line, type Service Network restart , restart card services

4. Check dns

Open /etc/resolv.conf with vim, to see whether the change dns server
vim /etc/resolv.conf
Here Insert Picture Description

4. Test Network

ping it, test the connection fails, or if dns can resolve the domain name ping www.baidu.com
or a ping ip address

5. Frequently Asked Questions: ping domain name appears unknown host domain name

Here Insert Picture Description
ping ip is on but can not resolve domain name:
     this is ifcfg-eth0 in dns did not write, or resolv.conf no change, no dns DNS server, resulting in domain name can not be resolved, to modify the ifcfg-eth0, then restart the network service .
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_41718454/article/details/97896911