参考博客:https://blog.csdn.net/yph001/article/details/80177154
https://blog.csdn.net/gaoganghua/article/details/80386107
1)ifconfig命令被用于配置和显示Linux内核中网络接口的网络参数
ifconfig
输出结果如下:
drew@ubun:~$ ifconfig
eth0 Link encap:以太网 硬件地址 d0:17:c2:aa:11:b8
inet 地址:10.0.4.33 广播:10.0.31.255 掩码:255.255.224.0
inet6 地址: fe80::d217:c2ff:feaa:11b8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:597503 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:123369 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:608806060 (608.8 MB) 发送字节:11350655 (11.3 MB)
lo Link encap:本地环回
inet 地址:127.0.0.1 掩码:255.0.0.0
inet6 地址: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 跃点数:1
接收数据包:2488 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:2488 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:259564 (259.5 KB) 发送字节:259564 (259.5 KB)
2)使用nm-tool来查看查看IP,网关,DNS
nm-tool
输出结果为:
drew@ubun:~$ nm-tool
NetworkManager Tool
State: connected (global)
- Device: eth0 [有线连接 1] -----------------------------------------------
Type: Wired
Driver: r8169
State: connected
Default: yes
HW Address: D0:17:C2:AA:11:B8
Capabilities:
Carrier Detect: yes
Speed: 1000 Mb/s
Wired Properties
Carrier: on
IPv4 Settings:
Address: 10.0.4.33
Prefix: 19 (255.255.224.0)
Gateway: 10.0.0.1
DNS: 119.29.29.29
DNS: 119.28.28.28
3)查看内核 IP 路由表
netstat -rn
输出结果为:
drew@ubun:~$ netstat -rn
内核 IP 路由表
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth0
10.0.0.0 0.0.0.0 255.255.224.0 U 0 0 0 eth0
网络通信的基本流程
路由器A ================================路由器B
| INTERNET |
| |
交换机A 交换机B
| | | |
| | | |
PC-A PC-B PC-C PC-D
其中,一般来说,路由器的LAN接口的IP地址就是你所在局域网中的网关,是连接内网和外网用的设备。
drew@ubun:~$ ping -c 3 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.174 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.170 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.135 ms
--- 10.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.135/0.159/0.174/0.022 ms
drew@ubun:~$ ping -c 3 119.28.28.28
PING 119.28.28.28 (119.28.28.28) 56(84) bytes of data.
64 bytes from 119.28.28.28: icmp_seq=1 ttl=44 time=38.6 ms
64 bytes from 119.28.28.28: icmp_seq=2 ttl=44 time=38.8 ms
64 bytes from 119.28.28.28: icmp_seq=3 ttl=44 time=38.6 ms
--- 119.28.28.28 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 38.627/38.704/38.810/0.239 ms
drew@ubun:~$ ping www.baidu.com
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38: icmp_seq=1 ttl=56 time=5.95 ms
64 bytes from 14.215.177.38: icmp_seq=2 ttl=56 time=5.86 ms
64 bytes from 14.215.177.38: icmp_seq=3 ttl=56 time=5.73 ms
64 bytes from 14.215.177.38: icmp_seq=4 ttl=56 time=6.05 ms
64 bytes from 14.215.177.38: icmp_seq=5 ttl=56 time=8.03 ms
64 bytes from 14.215.177.38: icmp_seq=6 ttl=56 time=5.94 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 5.738/6.265/8.034/0.799 ms
结果分析
感谢原文作者@yph001 https://blog.csdn.net/yph001/article/details/80177154
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。