Centos 7 starts replacing the previous ifconfig with the IP command
IP [Options] Action object {Link|addr|route ...}
# IP Link Show # Displays network interface information
# IP Link set eth0 UPI # Open Nic
# IP Link set eth0 down # close NIC
# IP Link set eth0 promisc on # open NIC Mixed mode
# IP Link Set eth0 promisc offi # Turn off the network card mix mode
# IP Link Set eth0 txqueuelen 1200 # set NIC Queue Length
# IP Link Set eth0 MTU 1400 # set NIC Maximum transmission unit
# IP Addr Show # Displays network card IP information
# ip addr Add 192.168.0.1/24 dev eth0 # set eth0 NIC IP address 192.168.0.1
# ip addr del 192.168.0.1/24 dev eth0 # remove eth0 NIC IP address
# IP Route List # view routing information
# IP route add 192.168.4.0/24 via 192.168.0.254 Dev eth0 # Set the gateway for 192.168.4.0 segment to 192.168.0.254, Data walk eth0 interface
# IP route add default via 192.168.0.254 Dev Eth0 # to set the defaults gateway to 192.168.0.254
# ip Route del 192.168.4.0/24 # Remove gateway for 192.168.4.0 network segment
# IP Route del Default # to delete the defaults route
Turn on Auto get
First look at your network card information
IP addr Show
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN
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:eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0c:29:c9:9b:0b BRD FF:FF:FF:FF:FF:FF
You can view the network card name as eno16777736
Enter network-scripts
[Email protected] ~]# cd/etc/sysconfig/network-scripts
[[email protected] network-scripts]# ls
ifcfg-eno16777736 ifdown-eth ifdown-isdn ifdown-sit ifup ifup-ib ifup-plip ifup-routes ifup-t Unnel Network-functions-ipv6
Ifcfg-lo Ifdown-ib ifdown-post ifdown-team ifup-aliases ifup-ippp ifup-plusb ifup-sit ifup-w Ireless
Ifdown ifdown-ippp ifdown-ppp ifdown-teamport ifup-bnep ifup-ipv6 ifup-post ifup-team init.i Pv6-global
IFDOWN-BNEP Ifdown-ipv6 ifdown-routes ifdown-tunnel ifup-eth ifup-isdn ifup-ppp ifup-teamport networ K-functions
[Email protected] network-scripts]#
Can see the configuration file of our corresponding network card is ifcfg-eno16777736
Using VI ifcfg-eno16777736
Go to edit
Type=ethernet
Bootproto=dhcp
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=no
Ipv6init=yes
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_peerdns=yes
Ipv6_peerroutes=yes
Ipv6_failure_fatal=no
name=eno16777736
uuid=5b96b479-11f3-4aec-b984-129de5721e7b
device=eno16777736
Onboot=no
Change Onboot=no to Onboot=yes and save exit restart
Reboot and use IP addr show to see
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN
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:eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0c:29:c9:9b:0b BRD FF:FF:FF:FF:FF:FF
inet 192.168.133.133/24 BRD 192.168.133.255 scope Global Dynamic eno16777736
Valid_lft 1252sec preferred_lft 1252sec
Inet6 FE80::20C:29FF:FEC9:9B0B/64 Scope link
Valid_lft Forever Preferred_lft Forever
Our network card has been automatically acquired to the IP
Set the IP address manually:
Type=ethernet
#BOOTPROTO =DHCP
Defroute=yes
Peerdns=yes
Peerroutes=yes
Ipv4_failure_fatal=no
Ipv6init=yes
Ipv6_autoconf=yes
Ipv6_defroute=yes
Ipv6_peerdns=yes
Ipv6_peerroutes=yes
Ipv6_failure_fatal=no
name=eno16777736
uuid=5b96b479-11f3-4aec-b984-129de5721e7b
device=eno16777736
Onboot=yes
ipaddr0=192.168.133.130
Prefix0=24
getway0=192.168.133.2
dns1=192.68.133.2
dns2=218.85.152.99
Configured through the above. We specify the IP subnet mask gateway and the DNS address for the system.
[[Email protected] ~]# IP addr Show
1:lo: <LOOPBACK,UP,LOWER_UP> MTU 65536 qdisc noqueue State UNKNOWN
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:eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000
Link/ether 00:0c:29:c9:9b:0b BRD FF:FF:FF:FF:FF:FF
inet 192.168.133.130/24 BRD 192.168.133.255 Scope Global eno16777736
Valid_lft Forever Preferred_lft Forever
Inet6 FE80::20C:29FF:FEC9:9B0B/64 Scope link
Valid_lft Forever Preferred_lft Forever
It is customary to use ifconfig to use Ifconfig to install Net-tools components via the Yum installation Net-tools after networking.
Centos 7 Network configuration