See 7 network interface information
- View all active network interfaces
- ifconfig command
[root@localhost ~]# ifconfig //查看网络接口信息 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.144.133 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 6139 bytes 3599390 (3.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2483 bytes 330519 (322.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 84 bytes 7500 (7.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 84 bytes 7500 (7.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:d9:de:d2 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- Check specify the network interface information
- ifconfig network interface
[root@localhost ~]# ifconfig ens33 //查看ens33网络接口信息 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.144.133 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 6183 bytes 3602858 (3.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2505 bytes 334073 (326.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
View Host Name
- View or set the current host name
- hostname command
[root @ localhost ~] # hostname // View hostname localhost.localdomain
- Change the hostname
- hostnamectl set-hostname [hostname]
[root @ localhost ~] # hostnamectl set-hostname http01 // change the hostname [root @ localhost ~] # su // switch users, refresh hostname [root @ http01 ~] # hostname // View Host Name http01
View the routing table entries
- View the routing table
- route command
[root@http01 ~]# route //查看路由表 Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 100 0 0 ens33 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.144.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33
View network connections
-
View the status of the network connection system, routing tables, interface statistics and other information
- netstat command
netstat [options]
- Common options
-a: All
-n: digital format
-p: Agreement
-t :tcp
-u :udp
-r: Routing
[root @ http01 ~] # netstat -antp // View displays all network connections TCP protocol port is used in a digital format the Active Internet Connections (Servers and the ESTABLISHED) Proto Recv-Q the Send-Q Local Address Foreign Address State PID / Program name tcp 0.0.0.0:111 0.0.0.0:* the LISTEN. 1 0 0 / systemd TCP 1308 0 0 192.168.122.1:53 0.0.0.0:* the LISTEN / dnsmasq TCP 983 0 0 0.0.0.0:22 0.0.0.0:* the LISTEN / the sshd 0 0 127.0.0.1:631 0.0.0.0:* the LISTEN TCP 985 / the cupsd TCP 1292 0 0 127.0.0.1:25 0.0.0.0:* the LISTEN / Master tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4840 / sshd: root @ PTS 0 0 192.168.144.133:22 192.168.144.1:54734 the ESTABLISHED TCP 4840 / the sshd: the root @ PTS TCP6 0 0 111 ::: ::: * the LISTEN. 1 / systemd TCP6 0 0 80 ::: ::: the LISTEN * 2373 / the httpd TCP6 0 0 ::: ::: 22 is the LISTEN * 983 / the sshd TCP6 0 :: 0. 1: 631 ::: 985 * the LISTEN / the cupsd tcp6 0 0 ::1:25 :::* LISTEN 1292/master TCP6 0 :: 0. 1: 6010 ::: 4840 * the LISTEN / the sshd: the root @pts [root @ http01 ~] # netstat -nuap // view is displayed in digital format all the UDP protocol network connection port Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 0.0.0.0:36571 0.0.0.0:* 788/dhclient udp 0 0 0.0.0.0:47956 0.0.0.0:* 578/avahi-daemon: r udp 0 0 192.168.122.1:53 0.0.0.0:* 1308/dnsmasq udp 0 0 0.0.0.0:67 0.0.0.0:* 1308/dnsmasq udp 0 0 0.0.0.0:68 0.0.0.0:* 788/dhclient 578 0 0 0.0.0.0:5353 0.0.0.0:* UDP / for avahi-daemon: R & lt udp 0 0 127.0.0.1:323 0.0.0.0:* 636/chronyd 0 0 ::: 57996 ::: udp6 * 788 / dhclient udp6 :: 0 0 1: 323 ::: * 636 / chronyd [root @ http01 ~] # netstat -r // Display route, the same route command role Table routing the IP kernel the Destination Gateway Genmask-the Flags the Window irtt that the MSS Iface default Gateway 0.0.0.0 UG 0 0 0 ens33 192.168.122.0 0 0 0 0.0.0.0 255.255.255.0 the U-virbr0 192.168.144.0 0 0 0 0.0.0.0 255.255.255.0 the U-ens33
Network connection tests
-
Testing of network communications
- ping command
ping [hostname] / [IP address]
[root@http01 ~]# ping 192.168.100.10 //测试网络通讯 PING 192.168.100.10 (192.168.100.10) 56(84) bytes of data. 64 bytes from 192.168.100.10: icmp_seq=1 ttl=128 time=0.860 ms 64 bytes from 192.168.100.10: icmp_seq=2 ttl=128 time=0.530 ms 64 bytes from 192.168.100.10: icmp_seq=3 ttl=128 time=0.514 ms 64 bytes from 192.168.100.10: icmp_seq=4 ttl=128 time=0.465 ms
Trace packet
-
Test network node passes between the host and the destination from the current
- traceroute command
traceroute destination host address
[root@http01 ~]# traceroute 192.168.100.10 traceroute to 192.168.100.10 (192.168.100.10), 30 hops max, 60 byte packets 1 gateway (192.168.144.2) 0.320 ms 0.255 ms 0.223 ms 2 * * * 3 * * * 4 * * *
DNS
-
Test DNS name resolution
- nslookup command
the nslookup [Target Host Address] / [Target Address DNS]
[root@http01 ~]# nslookup www.baidu.com Server: 192.168.144.2 Address: 192.168.144.2#53 Non-authoritative answer: www.baidu.com canonical name = www.a.shifen.com. Name: www.a.shifen.com Address: 183.232.231.172 Name: www.a.shifen.com Address: 183.232.231.174
Setting network parameters manner
Temporary Configuration - to adjust the network parameters using the command
-
Simple, fast, can directly modify the operation of the network parameters
-
Generally only suitable for use in the process of debugging the network
- After the restart, the changes made will fail
Fixed - to modify the network configuration file parameters
- Modify the configuration file of the network parameters
- Suitable for use when fixed parameter settings server
- Network services need to reload or restart to take effect later
Setting parameters of the network interface
-
Temporarily set the network interface IP address, subnet mask
ifconfig interface name IP address [netmask (subnet mask)]
[root @ http01 ~] # ifconfig ens33 // View ens33 interface IP address ens33: flags = 4163 <UP, BROADCAST, the RUNNING, MULTICAST> MTU 1500 inet Netmask 255.255.255.0 192.168.144.133 192.168.144.255 Broadcast inet6 fe80 :: a85a: C203: E2E: 3f3c the prefixlen 64 ScopeID 0x20 <Link> ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 42 is bytes 3966 (3.8 KiB) the RX errors 0 Dropped 0 overruns 0 Frame 0 the TX packets 86 9346 bytes (9.1 KiB) TX errors dropped Total 0 0 0 overruns Carrier 0 Collisions 0 [root @ http01 ~] # ifconfig ens33 192.168.144.138/24 // set the temporary IP address [root @ http01 ~] # ifconfig ens33 // see if successfully set ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.144.138 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 2660 bytes 3613441 (3.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 844 bytes 57384 (56.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@http01 ~]# systemctl restart network //重启网络服务 [root@http01 ~]# ifconfig ens33 //查看IP地址 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.144.133 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::a85a:c203:e2e:3f3c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) //设置的IP地址失效 RX packets 2708 bytes 3618185 (3.4 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 894 bytes 63590 (62.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
Set a fixed network interface IP address, subnet mask,
Set a fixed network interface IP address, subnet mask, we need to change the configuration file on the network interface in the configuration file to complete.
-
The network interface configuration files
/etc/sysconfig/network-scripts/
-
Restart network services network
systemctl restart network
[root @ http01 ~] # vim / etc / sysconfig / network-scripts / ifcfg-ens33 // enter the editing card configuration file the TYPE = Ethernet PROXY_METHOD = none BROWSER_ONLY = NO BOOTPROTO = staticl // Change the DHCP staticl DEFROUTE = yes IPV4_FAILURE_FATAL NO = IPV6INIT = Yes IPV6_AUTOCONF = Yes IPV6_DEFROUTE = Yes IPV6_FAILURE_FATAL = NO IPV6_ADDR_GEN_MODE = Privacy the stable- NAME = ens33 the UUID = 2ef6b862-5201-48c5-a450-23b3720ab3a0 the DEVICE = ens33 the ONBOOT Yes = the IPADDR = 192.168.144.138 // to set input IP address NETMAS = 255.255.255.0 // enter the subnet mask gATEWAY = 192.168.144.1 // input gateway address [root @ http01 ~] # systemctl restart network // network service restart [root @ http01 ~] # ifconfig ens33 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.144.138 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::20c:29ff:fe5b:d3a0 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) //地址设置成功 RX packets 3832 bytes 3715216 (3.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1558 bytes 160876 (157.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-
Disable or re-activate the card
- Disable network card
ifconfig network interface down
- Re-activate the card
ifconfig network interface up
[root @ localhost ~] # ifconfig ens33 down // disable the card [root @ localhost ~] # ifconfig ens33 // View card information, no IP address to connect ens33: flags = 4098 <BROADCAST, MULTICAST> MTU 1500 ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 459 bytes 495 831 (484.2 KiB) the RX errors 0 Dropped 0 overruns 0 Frame 0 the TX packets 240 bytes 22865 (22.3 KiB) the TX errors 0 Dropped 0 overruns 0 Carrier 0 Collisions 0
[root @ localhost ~] # ifconfig ens33 up // re-activate the card [root @ localhost ~] # ifconfig ens33 // View card information, obtain an IP address ens33: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500 Broadcast Netmask 255.255.255.0 192.168.144.255 192.168.144.133 inet inet6 FE80 :: a85a: C203: E2E: 64 3f3c the prefixlen ScopeID 0x20 <Link> ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 463 496 409 bytes (484.7 KiB) the RX errors Dropped 0 0 0 Frame 0 overruns the TX 26630 bytes packets 264 (26.0 KiB) the TX errors Dropped 0 0 0 overruns Carrier 0 0 Collisions
-
Virtual Network Interface
- Virtual Network Interface refers to share a network card, the same card can be equipped with multiple IP addresses, regardless of which IP addresses can access the same server access. (When not want to use the virtual card directly disable virtual card required)
ifconfig interface name: No. IP address
[root @ localhost ~] # ifconfig ens33: 0 192.168.144.140 // add on ens33 virtual NIC card, serial number is 0 [root @ localhost ~] # ifconfig // View card information ens33: flags = 4163 <UP, BROADCAST , the RUNNING, the MULTICAST> 1500 MTU inet Netmask 255.255.255.0 192.168.144.133 192.168.144.255 Broadcast inet6 FE80 :: a85a: C203: E2E: 64 3f3c the prefixlen ScopeID 0x20 <Link> ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 653 512686 bytes (500.6 KiB) the RX errors Dropped 0 0 0 Frame 0 overruns the TX 373 bytes packets 39 897 (38.9 KiB) the TX errors Dropped 0 0 0 overruns Collisions Carrier 0 0 ens33: 0: the flags = 4163 < UP, BROADCAST, RUNNING, MULTICAST> mtu 1500 // create a virtual network adapter inet Netmask 255.255.255.0 192.168.144.140 broadcast 192.168.144.255 ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) ...//省略部分内容...
Set the routing record
-
Add a route to record the specified network.
- route add -net network address gw IP address (gateway)
-
Delete the route to record the specified network.
- route del -net network address
-
Delete the default gateway routing table records
- route del default gw IP address
- Add records to the default gateway routing table
- route add default gw IP address
[root @ localhost ~] # route // Check the routing table Kernel IP routing the Table Destination Gateway Flags Metric Ref Genmask the Use Iface default Gateway 100 0.0.0.0 UG 0 0 ens33 192.168.122.0 255.255.255.0 0.0.0.0 U 0 0 0 virbr0 192.168 0.0.0.0 255.255.255.0 U 0 100 .144.0 0 ens33 [root @ localhost ~] # -net 192.168.100.0/24 the Add route gw 192.168.144.1 // add segments [root @ localhost ~] # route // View route table whether to add the network segment Kernel IP routing the table Destination Gateway Flags Metric Ref Genmask the Use Iface default Gateway 0.0.0.0 UG 100 0 0 ens33 192.168.100.0 192.168.144.1 255.255.255.0 UG 0 0 0 ens33 0.0.0.0 U 0 0 255.255.255.0 192.168.122.0 0 virbr0 192.168.144.0 255.255.255.0 0.0.0.0 U 0 0 100 ens33 [root @ localhost ~] # route del -net 192.168.100.0/24 // delete the added network section [root @ localhost ~] # route // Check the routing table to see whether the added segment delete Kernel IP routing the table Destination Gateway Flags Metric Ref Genmask the Use Iface default Gateway 100 0.0.0.0 UG 0 0 ens33 192.168.122.0 0.0.0.0 U 0 0 0 virbr0 255.255.255.0 [root @ localhost ~] # route // see if successfully added default gateway Kernel IP routing table 192.168.144.0 0.0.0.0 255.255.255.0 the U-100 0 0 ens33 [root @ localhost ~] # route add default gw 192.168.144.1 // add a default gateway Destination Gateway Flags Metric Ref Genmask the Use Iface default Gateway 0.0.0.0 UG 0 0 0 ens33 default Gateway 100 0.0.0.0 UG 0 0 ens33 192.168.122.0 255.255.255.0 U 0 0 0 0.0.0.0 virbr0 192.168.144.0 255.255.255.0 0.0.0.0 U 0 0 100 ens33 default gateway [root @ localhost ~] # route del default gw 192.168.144.1 // delete the added [root @ localhost ~] # route // View the routing table is successfully deleted Kernel IP routing the table Destination Gateway Flags Metric Ref Genmask the Use Iface default gateway 0.0 UG 100 0 0 ens33 .0.0 192.168.122.0 0 0 0 0.0.0.0 255.255.255.0 the U-virbr0 192.168.144.0 255.255.255.0 0.0.0.0 In 100 0 0 ens33
Host name of the profile
-
Save Global network settings, including host name information
/etc/sysconfig/network//etc/hostname
In CentOS 6 To modify the host name can perform "vim / etc / sysconfig / network" modify the configuration file, and in CentOS 7 we can perform "vim / etc / hostname" can go to modify the host name of the configuration file.
[root @ localhost ~] # vim / etc / hostname // hostname configuration file into the editor localhost.localdomain // hostname should the current modification can modify the host name directly in the editor ~ ~ ~ ~ ~ ~
DNS configuration files
-
Designated as the body providing DNS resolution server address (to change the file modification will be effective immediately)
- /etc/resolv.conf
- format
- nameserver IP address
[root@localhost ~]# vim /etc/resolv.conf # Generated by NetworkManager search localdomain nameserver 192.168.144.2 ~ ~ ~ ~
Local host mapping file
In the local host mapping file, add the mapping records, when added to the site visit records will be sent web requests, omit the process of resolving IP addresses to the DNS server directly to the IP address mapping records added.
-
Save record mapping host names and IP addresses
- /etc/hosts
- Compare hosts file and DNS servers
- By default, the system first looks resolution records from the hosts file
- hosts file is only valid for the current host
- hosts file can reduce DNS query process, thus speeding up access speed
to add on:
Establishing dual-card
Will inevitably encounter situations need to establish dual-card in daily production activities, here we take a look at how to create a dual-NIC
1, first add the virtual machine Linux operating system in a physical network adapter, and then view the network interface information to determine whether the network successfully added
[root @ localhost ~] # ifconfig // view network interface information ens33: flags = 4163 <UP, BROADCAST, the RUNNING, MULTICAST> MTU 1500 inet Netmask 255.255.255.0 192.168.144.133 192.168.144.255 Broadcast inet6 fe80 :: a85a: C203: E2E: 3f3c the prefixlen 64 ScopeID 0x20 <Link> ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 3415 bytes 740 748 (723.3 KiB) the RX errors 0 Dropped 0 overruns 0 Frame 0 the TX packets 1725 bytes 201 799 (197.0 KiB) the TX errors Dropped 0 0 0 overruns Collisions Carrier 0 0 ens36: the flags = 4163 <the UP, BROADCAST, the RUNNING, the MULTICAST> 1500 // physical NIC MTU newly added inet 192.168.144.141 netmask 255.255.255.0 broadcast 192.168.144.255 inet6 fe80::deb1:3cec:3e26:5ec2 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:aa txqueuelen 1000 (Ethernet) RX packets 85 bytes 6069 (5.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 30 bytes 4667 (4.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2, this time we see the network card configuration file directory to see if there are network card configuration file to add
[root @ localhost ~] # cd / etc / sysconfig / network-scripts / // into the network card configuration file directory [root @ localhost network-scripts] # ls // view, not this time when the newly added card ens36 profile of the ifcfg-ens33 ifdown-IPv6 ifdown-TeamPort the ifup-IPPP the ifup-routes Network-Functions the ifcfg-LO ifdown-ISDN ifdown-Tunnel the ifup-IPv6 the ifup-SIT Network-Functions-IPv6 ifdown ifdown-POST the ifup the ifup-ISDN the ifup-Team PPP-BNEP-ifdown ifdown the ifup-aliases the ifup-PLIP-TeamPort the ifup ifdown ifdown-Eth-BNEP the ifup-routes the ifup-Tunnel-plusb the ifup ifdown ifdown-IB-Eth-SIT the ifup the ifup-POST-Wireless the ifup ifdown-IPPP ifdown- Team ifup-ib ifup-ppp init.ipv6 -global
3, because no configuration file ens36 card, we have no way to specify a fixed address to ens36. Let's put ens36 and ens33 two network cards connected all set to host only mode, and then view network interface information.
[root @ localhost ~] # ifconfig // view network interface information ens33: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500 // not obtain an IP address inet6 fe80 :: a85a: c203: e2e : 3f3c prefixlen 64 scopeid 0x20 <Link> ether 00: 0c: 29: 5B: D3: A0 txqueuelen 1000 (Ethernet) the RX packets 3578 bytes 754 392 (736.7 KiB) the RX errors 0 Dropped 0 overruns 0 Frame 0 the TX packets 1812 bytes 215 065 (210.0 KiB) the TX errors Dropped overruns 0 0 Carrier 0 0 0 Collisions ens36: the flags = 4163 <the UP, BROADCAST, the RUNNING, the MULTICAST> // no hair MTU 1500 obtains an IP address inet6 fe80 :: deb1: 3cec: 3e26 : 5ec2 prefixlen 64 scopeid 0x20 <link> ether 00: 0c: 29: 5b : d3: aa txqueuelen 1000 (Ethernet) : 5ec2 prefixlen 64 scopeid 0x20 <link> RX packets 160 bytes 12321 (12.0 KiB ) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 48 bytes 7865 (7.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I can not obtain an IP address here because of a VMware virtual machine DHCP service turned off, so I can not get an address.
4, this time we give these two physical cards with a fixed address
[root @ localhost ~] # vim / etc / sysconfig / network-scripts / ifcfg-ens33 // edit card information on the TYPE = Ethernet PROXY_METHOD = none BROWSER_ONLY = NO BOOTPROTO = static dhcp // Change the static DEFROUTE = yes IPV4_FAILURE_FATAL = NO IPV6INIT Yes = IPV6_AUTOCONF = Yes IPV6_DEFROUTE = Yes IPV6_FAILURE_FATAL = NO IPV6_ADDR_GEN_MODE = Privacy the stable- NAME = ens33 the UUID = 2ef6b862-5201-48c5-a450-23b3720ab3a0 the DEVICE = ens33 the ONBOOT Yes = the IPADDR = IP address 192.168.100.10 // input arrangement NETMAS = 255.255 // enter the subnet mask .255.0 gATEWAY = 192.168.100.0 // input gateway configuration ~ ~ ~ ~ ~ ~ ~ : WQ [root @ localhost ~] # restart // Network Service Network Service Restart Restarting network (via systemctl): [OK] [root @ localhost ~] # ifconfig // view network interface information, see address is configured into effect ens33: flags = 4163 <UP , BROADCAST, the RUNNING, MULTICAST> MTU 1500 inet 192.168.100.10 192.168.100.255 Netmask 255.255.255.0 Broadcast inet6 fe80 :: a85a: C203: E2E: 3f3c prefixlen 64-scopeid 0x20 <Link> ether 00: 0c: 29:. 5B: D3: 1000 txqueuelen A0 (Ethernet) the RX 3642 bytes packets 771 191 (753.1 KiB) the RX errors Dropped 0 0 0 Frame 0 overruns the TX 1948 bytes packets 239 617 (234.0 KiB) the TX errors Dropped 0 0 0 overruns Carrier 0 0 Collisions
Here we enter the NIC configuration file directory, this time there is no profile ens36 card, we need to ens33 configuration files directly copy, change ens36 configuration file, and then change the contents of the configuration file on it
[root@localhost ~]# cd /etc/sysconfig/network-scripts/ //进入网卡配置文件目录 [root@localhost network-scripts]# ls //查看 ifcfg-ens33 ifdown-isdn ifup ifup-plip ifup-tunnel ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6 ifdown-ib ifdown-Team ifup-ippp ifup-sit ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort [root@localhost network-scripts]# cp -p ifcfg-ens33 ifcfg-ens36 //复制ens33配置文件 [root@localhost network-scripts]# ls //查看 ifcfg-ens33 ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort ifcfg-ens36 ifdown-isdn ifup ifup-plip ifup-tunnel ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6 ifdown-ib ifdown-Team ifup-ippp ifup-sit ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team [root @ localhost network-scripts] # vim ifcfg-ens36 // enter edit configuration files ens36 the TYPE = Ethernet PROXY_METHOD = none ~ Note configuration file inside the UUID entry to be deleted, the system automatically recognizes add on it (not the same UUID) BROWSER_ONLY=no BOOTPROTO=static Yes = DEFROUTE IPV4_FAILURE_FATAL = NO IPV6INIT = Yes IPV6_AUTOCONF = Yes IPV6_DEFROUTE = Yes IPV6_FAILURE_FATAL = NO IPV6_ADDR_GEN_MODE = Privacy the stable- NAME = ens36 // 33 to change 36 the DEVICE = ens36 33 to change // 36 the ONBOOT Yes = the IPADDR = 192.168.10.10 / / change the IP address of the network segment NETMAS = 255.255.255.0 gATEWAY = // change the gateway address 192.168.10.0 ~ ~ ~ ~ ~ ~ ~ : WQ [root @ localhost Network-scripts] # Service Network // restart to restart the network services Restarting network (via systemctl): [OK] [root @ localhost Network-scripts] # ifconfig // View card information ens33: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500 inet Broadcast Netmask 255.255.255.0 192.168.100.255 192.168.100.10 inet6 FE80 :: a85a: C203: E2E: 64 3f3c the prefixlen ScopeID 0x20 <Link> ether 00:0c:29:5b:d3:a0 txqueuelen 1000 (Ethernet) RX packets 3705 bytes 788818 (770.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1978 bytes 243934 (238.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 //成功获取IP地址 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::f6eb:23e3:3afb:fef4 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:5b:d3:aa txqueuelen 1000 (Ethernet) RX packets 248 bytes 33751 (32.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 280 bytes 49781 (48.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0