ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

46.第十章 网络协议和管理配置(七)

2021-11-16 17:02:01  阅读:200  来源: 互联网

标签:TX 46 网络协议 第十章 packets bytes usr 0.0 RX


3.5.7 划分子网

划分子网:将一个大的网络(主机数多)划分成多个小的网络(主机数少),主机ID位数变少,网络ID位数变多,网络ID位向主机ID位借位

划分子网的数量由网络ID向主机ID借的位决定

子网数量=2^网络ID向主机ID借位
在这里插入图片描述
可变长度子网掩码
在这里插入图片描述
Subnet地址
在这里插入图片描述
范例:

10.0.0.0/8

2^24-2

172.16.0.0/16

网段数=2^可变的网络ID位
一个网络的最大主机数=2^主机ID的位-2

主机ID位越多,主机数越多,网络越大
主机ID位数变少,主机数量越少,网络越小

划分子网: 

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

划分子网的数量由网络ID向主机ID借的位决定
子网数量=2^网络ID向主机ID借位

范例:

中国移动10.0.0.0/8 给32个各省公司划分对应的子网
1)每个省公司的子网的netmask?
2^5>=32 借5位网络ID
8+5=13
255.11111000.0.0
255.248.0.0

2)每个省公司的子网的主机数有多少?
2^(32-13)-2=524286

3)第一个子网的网络ID? 
10.00000 000.0.0
10.0.0.0/13

4)河南省得到第10个子网,网络ID?
10.01001 000.0.0/13
10.72.0.0/13

5)河南省得到第10个子网的最小IP和最大的IP?
10.01001 000.0.1
10.01001 111.11111111.11111110

10.72.0.1---10.79.255.254

6)所有子网中最大,最小的子网的网络ID(NETID)?
10.00000 000.0.0/13 10.0.0.0/13
10.11111 000.0.0/13 10.248.0.0/13

范例:

中国移动10.0.0.0/8  给32个省公司划分对应的子网,河南省得到第10个子网,再给省内的16个地市划分子网
10.01001 000.0.0 10.72.0.0/13

1)每个市公司的子网的netmask?
2^4>=16  借4位网络ID
13+4=17
255.255.128.0
2)每个市公司的子网的主机数有多少?
32-17=15  2^15-2=32766
3)各地市的最小netid和最大netid?
10.72.0.0-10.79.128.0

4)洛阳市第2个子网,最小IP和最大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 优化IP地址分配

在这里插入图片描述
合并超网:将多个小网络合并成一个大网,主机ID位向网络ID位借位,主要实现路由聚合功能

范例:

#2000个主机分配了8个C类网段
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

#合并成
220.78.168.0/21

3.5.9 跨网络通信

跨网络通信:路由,选择路径

路由分类:

  • 主机路由
  • 网络路由
  • 默认路由

优先级:精度越高,优先级越高

3.5.10 动态主机配置协议 DHCP

在这里插入图片描述

4.网络配置

4.1 基本网络配置

将Linux主机接入到网络,需要配置网络相关设置

一般包括如下内容:

  • 主机名

  • IP/netmask

  • 路由:默认网关

  • DNS服务器

    主DNS服务器

    次DNS服务器

    第三个DNS服务器

范例:

[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 CentOS 6 之前版本网卡名称

接口命名方式:CentOS 6

​ 以太网:eth[0,1,2,…]

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

网络接口识别并命名相关的udev配置文件:

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

查看网卡:

​ dmesg |grep –i eth

​ ethtool -i eth0

卸载网卡驱动:

​ modprobe -r e1000

​ rmmod e1000

装载网卡驱动:

​ modprobe e1000

范例:临时修改网卡名称

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

范例:

#克隆一台centos6 主机出来
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
#ethtool -i eth1 查看网卡驱动为e1000

在这里插入图片描述
#modprobe -r e1000 卸载网卡驱动

在这里插入图片描述
#modprobe e1000 加载网卡驱动

在这里插入图片描述
在这里插入图片描述
#现在没有IP地址

在这里插入图片描述
#ifconfig eth0 172.31.0.66/21,临时修改IP地址

4.3 网络配置命令

4.3.1 网络配置方式

  • 静态指定:

    ifconfig, route, netstat

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

    system-config-network-tui,setup

    配置文件

  • 动态分配:DHCP: Dynamic Host Configuration Protocol

4.3.2 ifconfig命令

来自于net-tools包,建议使用 ip 代替

[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

注意:立即生效

启用混杂模式:[-]promisc

范例:

#添加一块网卡

[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)
#默认是看不到的

[root@centos6 ~]# ifconfig -a #可以看到被禁用的网卡
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 #启用网卡
[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 #设置网卡别名IP地址
[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 #禁用网卡别名

[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>
#禁用不了,因为eth1没有网卡配置文件
#ifdown  eth1只是删除了IP地址,ifconfig eth1 down  是禁用了网卡

[root@centos6 ~]# ifconfig eth1 0/0  这样也可以清除IP地址
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  统计网卡流量

[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 指定一次多少字节 ,最大65507字节

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

在这里插入图片描述
范例:

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

#清除eth0上面的IP地址
[root@rocky8 ~]# ifconfig eth0 0.0.0.0/0

#启用和禁用网卡
[root@rocky8 ~]# ifconfig eth0 down
[root@rocky8 ~]# ifconfig eth0 up

#对一个网卡设置多个IP地址
[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

范例:

[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

标签:TX,46,网络协议,第十章,packets,bytes,usr,0.0,RX
来源: https://blog.csdn.net/qq_25599925/article/details/120983994

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有