Chapter XII Network Management-centos7.5 knowledge
IP address management
hostnamectl set-hostname s1.test.com
nmcli general hostname s1.test.com
nmcli device status
nmcli device show ens32
nmtui
nmcli help
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
OPTIONS
-t[erse] terse output
-p[retty] pretty output
-m[ode] tabular|multiline output mode
-f[ields] |all|common specify fields to output
-e[scape] yes|no escape columns separators in values
-n[ocheck] don't check nmcli and NetworkManager versions
-a[sk] ask for missing parameters
-w[ait] set timeout waiting for finishing operations
-v[ersion] show program version
-h[elp] print this help
OBJECT
g[eneral] NetworkManager's general status and operations
n[etworking] overall networking control
r[adio] NetworkManager radio switches
c[onnection] NetworkManager's connections
d[evice] devices managed by NetworkManager
Note: network card command rules after centos 7
en Ethernet Ethernetwl Wireless local area network WLAN××× wireless wide area network WWANo on-board device index numbers hotplug slot index numberx MAC addressp PCI geograhical location/USB port number chain
Sequence number generated by system variable
Method modified to eth0 style
Edit/etc/default/grub and add "net.ifnames=0 biosdevname=0 "
grub2-mkconfig -o/boot/grub2/grub.cfg
command management
ifconfig
ifconfig eth2
ifconfig eth0 down
ifconfig eth0 up
ifconfig eth2 192.168.11.22 netmask 255.255.255.0 [ broadcast 192.168.11.255 ]
ifconfig eth0 192.168.11.10 netmask 255.255.255.0 [broadcast 255.255.255.0]
ifconfig eth0 hw ether 00:11:22:22:11:00
set the MAC address
ifconfig eth0:1 192.168.12.23 netmask 255.255.255.0
Add a child interface
ifconfig eth0 -arp
ifconfig eth0 arp
II. Route management route
1、route -n
display
2. Add routing
route add -net destination netmask x.gw next-hop route address
route add -net destination netmask x.x.x dev eth2
route add -net 172.18.11.0 netmask 255.255.255.0 gw 192.168.11.23
route add -host 172.18.11.67 gw 192.168.11.23 reject
route -host destination host gw next-hop route address
route add -host 172.18.11.67 gw 192.168.11.23
default gateway
route add default gw gateway address
route del default gw 192.168.11.23
delete a route
route del -net 172.18.11.0 netmask 255.255.255.0 gw 192.168.11.23
Third, command operation restart lost, forever saved setting method
1. Write these commands to/etc/rc.local;
2. Change the configuration file
Network card:
vi /etc/sysconfig/network-scripts/ifcfg-eth[0,1,2....]
DEVICE=eth2
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.91.20
NETMASK=255.255.255.0
#GATEWAY=192.168.91.1
Service network restart required to take effect (Note: Virtual machine to restart machine)
vi /etc/resolv.conf
nameserver 202.106.0.20
nameserver 222.222.222.222
routing
vi /etc/sysconfig/network-scripts/route-eth[0,1,2....]
192.168.30.0/24 via 192.168.91.10 dev eth2
or
192.168.30.0 netmask 255.255.255.0 via 192.168.91.10 dev eth2
IV. Command of network test
ping -c times 172.18.199.1
traceroute target detection route hops traversed
nslookup DNS detection resolution
arp -n detection arp analysis
Lab assignment:
1. Set up 2 LINUX servers. The first one has 2 network cards. Eth0 is the default network card of the system. No change is needed. Eth2 is 192.168. Student number. Student number;
The second machine has only one NIC, which is DHCP by default, and the IP address is added, 192.168. student number +100. student number. On the first machine, dynamic and static route addition methods are used to ping the sub-interface IP of the second machine.
Assignment:
1. Write a method to modify the IP address of centos 7.5;
2. Add the default gateway method.