CentOS physical machine command version network configuration details:
centos6: vim /etc/sysconfig/network-scripts/ifcfg-eth0 (network card name)
centos7: vim /etc/sysconfig/network-scripts/ifcfg-ens33 (network card name)
1. Execute with the highest authority root:
- [dell@localhost ~]$ about
- password:
2. View the network card name:
Line 8 of the code block (2: ens32) is the network card name, and so on if there are other network ports! !
[root@localhost dell]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:24:17:1c brd ff:ff:ff:ff:ff:ff
inet 192.168.10.11/24 brd 192.168.10.255 scope global noprefixroute dynamic ens32
valid_lft 7172sec preferred_lft 7172sec
inet6 fe80::bdd9:140c:83f:43d8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:af:09:ea brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:af:09:ea brd ff:ff:ff:ff:ff:ff
[root@localhost dell]#
3. Set dynamic ip:
It's more verbose here: but it's more detailed, and it's better for Xiaobai to understand! !
3.1 Execute network card configuration commands
Execute the network card configuration command - press Enter to enter the configuration interface:
[root@localhost dell]# vim /etc/sysconfig/network-scripts/ifcfg-ens32
3.2 Switch to insert mode
After entering, the interface is as follows: first press the lowercase i key to switch to insert mode:
YPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens32"
UUID="35e1237d-262e-45d6-a190-40806d0cd2a2"
DEVICE="ens32"
ONBOOT="yes"
~
~
~
~
~
~
~
~
~
~
"/etc/sysconfig/network-scripts/ifcfg-ens32" 15L, 310C
3.3 Enter the compilation state
When the lower left corner becomes inserted:
YPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens32"
UUID="35e1237d-262e-45d6-a190-40806d0cd2a2"
DEVICE="ens32"
ONBOOT="yes"
~
~
~
~
~
~
~
~
~
~
-- INSERT--
3.4 Enter the configuration state
Double-click and press the Esc key to return to the state without characters:
YPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens32"
UUID="35e1237d-262e-45d6-a190-40806d0cd2a2"
DEVICE="ens32"
ONBOOT="yes"
~
3.5 Modify dynamic configuration content
Note:
ONBOOT=yes state is to turn on the network card to start automatically
yes means to load the network, no means not to load the network, it needs to be changed to yes state
BOOTPROTO=dhcp status (indicates that it is set to dynamic ip)
- TYPE="Ethernet"
- PROXY_METHOD="none"
- BROWSER_ONLY="no"
- BOOTPROTO="dhcp"
- DEFROUTE="yes"
- IPV4_FAILURE_FATAL="no"
- IPV6INIT="yes"
- IPV6_AUTOCONF="yes"
- IPV6_DEFROUTE="yes"
- IPV6_FAILURE_FATAL="no"
- IPV6_ADDR_GEN_MODE="stable-privacy"
- NAME="ens32"
- UUID="35e1237d-262e-45d6-a190-40806d0cd2a2"
- DEVICE="ens32"
- ONBOOT="yes"
3.6 Save and exit
Note: Finally: shift+colon, wq=save and exit
- TYPE="Ethernet"
- PROXY_METHOD="none"
- BROWSER_ONLY="no"
- BOOTPROTO="dhcp"
- DEFROUTE="yes"
- IPV4_FAILURE_FATAL="no"
- IPV6INIT="yes"
- IPV6_AUTOCONF="yes"
- IPV6_DEFROUTE="yes"
- IPV6_FAILURE_FATAL="no"
- IPV6_ADDR_GEN_MODE="stable-privacy"
- NAME="ens32"
- UUID="35e1237d-262e-45d6-a190-40806d0cd2a2"
- DEVICE="ens32"
- ONBOOT="yes"
- ~
- ~
- ~
- ~
- ~
- ~
- ~
- ~
- ~
- ~
- :wq
3.7 Test network
Note: ping baidu.com as shown in the figure below means that the network can be connected! ! cat+c to pause! !
- [root@localhost dell]# vim /etc/sysconfig/network-scripts/ifcfg-ens32
- [root@localhost dell]# ping baidu.com Note: ping baidu.com as shown in the figure below can connect to the network! !
- PING baidu.com (110.242.68.66) 56(84) bytes of data.
- 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=50 time=42.0 ms
- 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=50 time=41.8 ms
- 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=50 time=41.7 ms
- 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=4 ttl=50 time=41.7 ms
- ^C Note: cat+c to pause! !
- --- baidu.com ping statistics ---
- 4 packets transmitted, 4 received, 0% packet loss, time 3011ms
- rtt min/avg/max/mdev = 41.712/41.845/42.040/0.191 ms
- [root@localhost dell]#
First try, thank you for pointing out what's wrong!