Chapter 10 network protocol and management configuration

Keywords: Linux network architecture Network Protocol Cloud Native

3.5.7 sub network division

Sub network division: divide a large network (with more hosts) into multiple small networks (with less hosts), reduce the number of host ID bits, increase the number of network ID bits, and borrow the network ID bit from the host ID bit

The number of subnets divided is determined by the bits borrowed from the host ID by the network ID

Number of subnets = 2 ^ network ID borrow from host ID

Variable length subnet mask

Subnet address

example:

10.0.0.0/8

2^24-2

172.16.0.0/16

Number of network segments=2^Variable network ID position
 Maximum number of hosts in a network=2^host ID Bit of-2

host ID More bits,More hosts,The larger the network
 host ID Fewer digits,Fewer hosts,The smaller the network

Partition subnet: 

10.00  000000.0.0

10.0 0000000.0.1
10.1 1111111.255.254

10.0 0000000.0.0  10.0.0.0/9  
10.1 0000000.0.0  10.128.0.0/9

10.00000000.0.0 10.0.0.0/10
10.01000000.0.0 10.64.0.0/10
10.10000000.0.0 10.128.0.0/10
10.11000000.0.0 10.192.0.0/10

The number of subnets is determined by the network ID To host ID Borrow bit decision
 Number of subnets=2^network ID To host ID Borrow

example:

China Mobile 10.0.0.0/8 Corresponding subnets are divided for 32 provincial companies
1)Of subnets of each provincial company netmask?
2^5>=32 Borrow 5-bit network ID
8+5=13
255.11111000.0.0
255.248.0.0

2)How many hosts are there in the subnet of each provincial company?
2^(32-13)-2=524286

3)Network of the first subnet ID? 
10.00000 000.0.0
10.0.0.0/13

4)Henan province gets the 10th subnet, network ID?
10.01001 000.0.0/13
10.72.0.0/13

5)Henan province gets the minimum of the 10th subnet IP And the largest IP?
10.01001 000.0.1
10.01001 111.11111111.11111110

10.72.0.1---10.79.255.254

6)The network of the largest and smallest of all subnets ID(NETID)?
10.00000 000.0.0/13 10.0.0.0/13
10.11111 000.0.0/13 10.248.0.0/13

example:

China Mobile 10.0.0.0/8  The corresponding subnets are divided for 32 provincial companies, the 10th subnet is obtained in Henan Province, and then the subnets are divided for 16 prefectures and cities in the province
10.01001 000.0.0 10.72.0.0/13

1)The number of subnets per city company netmask?
2^4>=16  Borrow 4-bit network ID
13+4=17
255.255.128.0
2)How many hosts are there in the subnet of each city company?
32-17=15  2^15-2=32766
3)Minimum in each city netid And maximum netid?
10.72.0.0-10.79.128.0

4)Luoyang second subnet, minimum IP And maximum IP?
10.72.128.1-10.72.255.254

10.01001000.00000000.0/17 10.72.0.1-10.72.127.254
10.01001000.10000000.0/17 10.72.128.1-10.72.255.254 
10.01001001.00000000.0/17 10.73.0.1-10.73.127.254
10.01001001.10000000.0/17 10.73.128.0-10.73.255.254
10.01001010.00000000.0/17 10.74.0.1-10.74.127.254
10.01001010.10000000.0/17 10.74.128.1-10.74.255.254
10.01001011.00000000.0/17 10.75.0.1-10.75.127.254
10.01001011.10000000.0/17 10.75.128.1-10.75.255.254
10.01001100.00000000.0/17 10.76.0.1-10.76.127.254
10.01001100.10000000.0/17 10.76.128.1-10.76.255.254
10.01001101.00000000.0/17 10.77.0.1-10.77.127.254
10.01001101.10000000.0/17 10.77.128.1-10.77.255.254
10.01001110.00000000.0/17 10.78.0.1-10.78.127.254
10.01001110.10000000.0/17 10.78.128.1-10.255.254
10.01001111.00000000.0/17 10.79.0.1-10.79.127.254
10.01001111.10000000.0/17 10.79.128.1-10.79.255.254

3.5.8 optimize IP address allocation


Merge supernetwork: merge multiple small networks into a large network, and borrow the host ID bit from the network ID bit, mainly realizing the routing aggregation function

example:

#Eight class C network segments are allocated to 2000 hosts
220.78.168.0/24
220.78.169.0/24
220.78.170.0/24
220.78.171.0/24
220.78.172.0/24
220.78.173.0/24
220.78.174.0/24
220.78.175.0/24

220.78.10101 000.0 220.78.168.0/24
220.78.10101 001.0 220.78.169.0/24
220.78.10101 010.0 220.78.170.0/24
...
220.78.10101 110.0 220.78.174.0/24
220.78.10101 111.0 220.78.175.0/24

#Merge into
220.78.168.0/21

3.5.9 cross network communication

Cross network communication: routing, path selection

Routing classification:

  • Host routing
  • network route
  • Default route

Priority: the higher the precision, the higher the priority

3.5.10 Dynamic Host Configuration Protocol DHCP

4. Network configuration

4.1 basic network configuration

To connect the Linux host to the network, you need to configure network related settings

It generally includes the following contents:

  • host name

  • IP/netmask

  • Routing: default gateway

  • DNS server

    Primary DNS server

    Secondary DNS server

    Third DNS server

example:

[root@rocky8 ~]# hostname
rocky8
[root@rocky8 ~]# ping rocky8
PING rocky8(rocky8 (fe80::20c:29ff:fef9:6ad1%eth0)) 56 data bytes
64 bytes from rocky8 (fe80::20c:29ff:fef9:6ad1%eth0): icmp_seq=1 ttl=64 time=0.063 ms
64 bytes from rocky8 (fe80::20c:29ff:fef9:6ad1%eth0): icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from rocky8 (fe80::20c:29ff:fef9:6ad1%eth0): icmp_seq=3 ttl=64 time=0.036 ms
64 bytes from rocky8 (fe80::20c:29ff:fef9:6ad1%eth0): icmp_seq=4 ttl=64 time=0.042 ms
^C
--- rocky8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3079ms
rtt min/avg/max/mdev = 0.036/0.048/0.063/0.011 ms

4.2 network card name before CentOS 6

Interface naming method: CentOS 6

Ethernet: eth[0,1,2,...]

​ ppp: ppp[0,1,2,...]

The network interface identifies and names the related udev configuration files:

​ /etc/udev/rules.d/70-persistent-net.rules

View network card:

​ dmesg |grep –i eth

​ ethtool -i eth0

To uninstall the network card driver:

​ modprobe -r e1000

​ rmmod e1000

Load network card driver:

​ modprobe e1000

Example: temporarily modify the network card name

[root@centos6 ~]# ip link set eth0 down
[root@centos6 ~]# ip link set eth0 name abc
[root@centos6 ~]# ip link set abc up

example:

#Clone a CentOS 6 host


#ethtool -i eth1 view the network card driver as e1000


#modprobe -r e1000 uninstall network card driver


#modprobe e1000 loading network card driver



#There is no IP address now


#ifconfig eth0 172.31.0.66/21, temporarily modify the IP address

4.3 network configuration command

4.3.1 network configuration mode

  • Static assignment:

    ifconfig, route, netstat

    ip: object {link, addr, route}, ss, tc

    system-config-network-tui,setup

    configuration file

  • Dynamic allocation: DHCP: Dynamic Host Configuration Protocol

4.3.2 ifconfig command

From the net tools package, it is recommended to use ip instead

[root@rocky8 ~]# which ifconfig
/usr/sbin/ifconfig
[root@rocky8 ~]# rpm -qf `which ifconfig`
net-tools-2.0-0.52.20160912git.el8.x86_64
[root@rocky8 ~]# rpm -qi net-tools
Name        : net-tools
Version     : 2.0
Release     : 0.52.20160912git.el8
Architecture: x86_64
Install Date: Mon 25 Oct 2021 05:22:25 PM CST
Group       : System Environment/Base
Size        : 964894
License     : GPLv2+
Signature   : RSA/SHA256, Mon 12 Apr 2021 06:31:49 AM CST, Key ID 15af5dac6d745a60
Source RPM  : net-tools-2.0-0.52.20160912git.el8.src.rpm
Build Date  : Wed 07 Apr 2021 11:41:10 AM CST
Build Host  : ord1-prod-x86build001.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager    : infrastructure@rockylinux.org
Vendor      : Rocky
URL         : http://sourceforge.net/projects/net-tools/
Summary     : Basic networking tools
Description :
The net-tools package contains basic networking tools,
including ifconfig, netstat, route, and others.
Most of them are obsolete. For replacement check iproute package.

[root@rocky8 ~]# rpm -ql net-tools
/usr/bin/netstat
/usr/lib/.build-id
/usr/lib/.build-id/02
/usr/lib/.build-id/02/9bd2bbada4d981bd08eec1b69c417ec0540464
/usr/lib/.build-id/18
/usr/lib/.build-id/18/e13de699b88ffca36b146a8173afd31ffa4bfa
/usr/lib/.build-id/38
/usr/lib/.build-id/38/d5f513a2c3495d28e4aa0618ced7aa8b091719
/usr/lib/.build-id/3f
/usr/lib/.build-id/3f/7dd7b481bc94f655e33d5c48f82850cde2c2dd
/usr/lib/.build-id/40
/usr/lib/.build-id/40/7e45207270c9a482333d312954a9b57b1a4ef0
/usr/lib/.build-id/4b
/usr/lib/.build-id/4b/eae4ed5cd7e395e1affac0bb264b8060cc3855
/usr/lib/.build-id/88
/usr/lib/.build-id/88/26fdea3b3a6b0fb11618354fe056ee1170c2a1
/usr/lib/.build-id/93
/usr/lib/.build-id/93/66d7a14b144fd1470e4ded9971f70fb81feeba
/usr/lib/.build-id/98
/usr/lib/.build-id/98/655a9c5c9a4728d1c25101a56f3149fa10b329
/usr/lib/.build-id/a5
/usr/lib/.build-id/a5/ef7e9bb55436dc8eb3d2414afd40c1df134640
/usr/lib/.build-id/af
/usr/lib/.build-id/af/dcfd9fa89871631d511adc2fc5affac225d8eb
/usr/lib/.build-id/e4
/usr/lib/.build-id/e4/5566d09948e5656abffefaf0aa81521012e80f
/usr/lib/systemd/system/arp-ethers.service
/usr/sbin/arp
/usr/sbin/ether-wake
/usr/sbin/ifconfig
/usr/sbin/ipmaddr
/usr/sbin/iptunnel
/usr/sbin/mii-diag
/usr/sbin/mii-tool
/usr/sbin/nameif
/usr/sbin/plipconfig
/usr/sbin/route
/usr/sbin/slattach
/usr/share/licenses/net-tools
/usr/share/licenses/net-tools/COPYING
/usr/share/locale/cs/LC_MESSAGES/net-tools.mo
/usr/share/locale/de/LC_MESSAGES/net-tools.mo
/usr/share/locale/et_EE/LC_MESSAGES/net-tools.mo
/usr/share/locale/fr/LC_MESSAGES/net-tools.mo
/usr/share/locale/pt_BR/LC_MESSAGES/net-tools.mo
/usr/share/man/de/man5/ethers.5.gz
/usr/share/man/de/man8/arp.8.gz
/usr/share/man/de/man8/ifconfig.8.gz
/usr/share/man/de/man8/netstat.8.gz
/usr/share/man/de/man8/plipconfig.8.gz
/usr/share/man/de/man8/route.8.gz
/usr/share/man/de/man8/slattach.8.gz
/usr/share/man/fr/man5/ethers.5.gz
/usr/share/man/fr/man8/arp.8.gz
/usr/share/man/fr/man8/ifconfig.8.gz
/usr/share/man/fr/man8/netstat.8.gz
/usr/share/man/fr/man8/plipconfig.8.gz
/usr/share/man/fr/man8/route.8.gz
/usr/share/man/fr/man8/slattach.8.gz
/usr/share/man/man5/ethers.5.gz
/usr/share/man/man8/arp.8.gz
/usr/share/man/man8/ether-wake.8.gz
/usr/share/man/man8/ifconfig.8.gz
/usr/share/man/man8/ipmaddr.8.gz
/usr/share/man/man8/iptunnel.8.gz
/usr/share/man/man8/mii-diag.8.gz
/usr/share/man/man8/mii-tool.8.gz
/usr/share/man/man8/nameif.8.gz
/usr/share/man/man8/netstat.8.gz
/usr/share/man/man8/plipconfig.8.gz
/usr/share/man/man8/route.8.gz
/usr/share/man/man8/slattach.8.gz
/usr/share/man/pt/man8/arp.8.gz
/usr/share/man/pt/man8/ifconfig.8.gz
/usr/share/man/pt/man8/netstat.8.gz
/usr/share/man/pt/man8/route.8.gz

[root@rocky8 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.31.1.8  netmask 255.255.248.0  broadcast 172.31.7.255
        inet6 fe80::20c:29ff:fef9:6ad1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f9:6a:d1  txqueuelen 1000  (Ethernet)
        RX packets 22894  bytes 32929773 (31.4 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2364  bytes 214404 (209.3 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 1000  (Local Loopback)
        RX packets 8  bytes 832 (832.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 832 (832.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ifconfig [interface]
ifconfig -a
ifconfig IFACE [up|down]
ifconfig interface [aftype] options | address ...
ifconfig IFACE IP/netmask [up]
ifconfig IFACE IP netmask NETMASK

Note: effective immediately

Enable hybrid mode: [-] promisc

example:

#Add a network card

[root@centos6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.66  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:63f7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:87 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12998 (12.6 KiB)  TX bytes:11638 (11.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
#The default is invisible

[root@centos6 ~]# ifconfig -a #You can see the disabled network card
eth0      Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.66  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:63f7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:97 errors:0 dropped:0 overruns:0 frame:0
          TX packets:73 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:13888 (13.5 KiB)  TX bytes:13274 (12.9 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:18:63:01  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centos6 ~]# ifconfig eth1 up #Enable network card
[root@centos6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.66  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:63f7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:125 errors:0 dropped:0 overruns:0 frame:0
          TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:16390 (16.0 KiB)  TX bytes:16556 (16.1 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:18:63:01  
          inet6 addr: fe80::20c:29ff:fe18:6301/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:238 (238.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centos6 ~]# ifconfig eth0:1 172.31.0.76/21 #Set network card alias IP address
[root@centos6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.66  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:63f7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:201 errors:0 dropped:0 overruns:0 frame:0
          TX packets:144 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:23544 (22.9 KiB)  TX bytes:23762 (23.2 KiB)

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.76  Bcast:172.31.7.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth1      Link encap:Ethernet  HWaddr 00:0C:29:18:63:01  
          inet6 addr: fe80::20c:29ff:fe18:6301/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:468 (468.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centos6 ~]# ifconfig eth0:1 down #Disable network card alias

[root@centos6 ~]# ifconfig eth1 172.31.0.86/21
[root@centos6 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:18:63:F7  
          inet addr:172.31.0.66  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:63f7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:273 errors:0 dropped:0 overruns:0 frame:0
          TX packets:191 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:30284 (29.5 KiB)  TX bytes:30720 (30.0 KiB)

eth1      Link encap:Ethernet  HWaddr 00:0C:29:18:63:01  
          inet addr:172.31.0.86  Bcast:172.31.7.255  Mask:255.255.248.0
          inet6 addr: fe80::20c:29ff:fe18:6301/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 b)  TX bytes:468 (468.0 b)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@centos6 ~]# ifdown eth1
usage: ifdown <device name>
#Cannot be disabled because eth1 does not have a network card profile
#Ifdown eth1 only deletes the IP address. ifconfig eth1 down disables the network card

[root@centos6 ~]# ifconfig eth1 0/0 this also clears the IP address
SIOCSIFNETMASK: Cannot assign requested address
SIOCGIFADDR: Cannot assign requested address
SIOCSIFBROADCAST: Cannot assign requested address

[root@centos6 ~]# ifconfig -s
Iface   MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0      387      0      0      0      273      0      0      0 BMRU
eth1       1500   0        0      0      0      0        6      0      0      0 BMRU
lo        65536   0        0      0      0      0        0      0      0      0 LRU
#-s statistics network card traffic

[root@rocky8 ~]# watch -n0.5 ifconfig -s
Every 0.5s: ifconfig -s                                                                                        rocky8: Mon Oct 25 18:25:14 2021

Iface	   MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0             1500    22994      0	   0 0          2452	  0	 0	0 BMRU
eth1             1500        7      0	   0 0            16	  0	 0	0 BMRU
lo              65536        8      0	   0 0             8	  0	 0	0 LRU

[root@centos7 ~]# ping -f 172.31.1.8 #-F flood
PING 172.31.1.8 (172.31.1.8) 56(84) bytes of data.

[root@centos7 ~]# ping -s 65508 -f 172.31.1.8
Error: packet size 65508 is too large. Maximum is 65507
#-s specifies the number of bytes at a time, up to 65507 bytes

[root@centos7 ~]# ping -s 65507 -f 172.31.1.8
PING 172.31.1.8 (172.31.1.8) 65507(65535) bytes of data.


example:

[root@rocky8 ~]# ifconfig eth0 10.0.0.68 netmask 255.255.0.0

#Clear the IP address above eth0
[root@rocky8 ~]# ifconfig eth0 0.0.0.0/0

#Enable and disable network card
[root@rocky8 ~]# ifconfig eth0 down
[root@rocky8 ~]# ifconfig eth0 up

#Set multiple IP addresses for a network card
[root@rocky8 ~]# ifconfig eth0:1 172.16.0.8/24
[root@rocky8 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.31.1.8  netmask 255.255.248.0  broadcast 172.31.7.255
        inet6 fe80::20c:29ff:fef9:6ad1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f9:6a:d1  txqueuelen 1000  (Ethernet)
        RX packets 22234  bytes 32826530 (31.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1892  bytes 160671 (156.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.16.0.8  netmask 255.255.255.0  broadcast 172.16.0.255
        ether 00:0c:29:f9:6a:d1  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 1000  (Local Loopback)
        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

[root@rocky8 ~]# ifconfig eth0:1 down
[root@rocky8 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.31.1.8  netmask 255.255.248.0  broadcast 172.31.7.255
        inet6 fe80::20c:29ff:fef9:6ad1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f9:6a:d1  txqueuelen 1000  (Ethernet)
        RX packets 22244  bytes 32827424 (31.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1900  bytes 162751 (158.9 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 1000  (Local Loopback)
        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

example:

[root@rocky8 ~]# ifconfig -s
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0             1500    22251      0      0 0          1908      0      0      0 BMRU
lo              65536        0      0      0 0             0      0      0      0 LRU
[root@rocky8 ~]# ifconfig -s eth0
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0             1500    22265      0      0 0          1917      0      0      0 BMRU

Posted by Darghon on Tue, 16 Nov 2021 02:00:41 -0800