栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

linux下网络故障常用的几个命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux下网络故障常用的几个命令

linux下网络故障常用的几个命令 ifconfig
ubuntu@VM-0-3-ubuntu:~$ ifconfig
docker0: flags=4099  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:49:13:91:23  txqueuelen 0  (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
​
eth0: flags=4163  mtu 1500
        inet 172.16.0.3  netmask 255.255.240.0  broadcast 172.16.15.255
        inet6 fe80::5054:ff:fe9b:8405  prefixlen 64  scopeid 0x20
        ether 52:54:00:9b:84:05  txqueuelen 1000  (Ethernet)
        RX packets 48359052  bytes 4512423724 (4.5 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47191232  bytes 4195297257 (4.1 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
​
lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1352984  bytes 110930762 (110.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1352984  bytes 110930762 (110.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
​

可以方便的查看本机的几个网卡

ping
ubuntu@VM-0-3-ubuntu:~$ ping www.baidu.com
PING www.a.shifen.com (14.215.177.39) 56(84) bytes of data.
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=1 ttl=54 time=2.88 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=54 time=2.79 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=54 time=2.78 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=54 time=2.84 ms
64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=5 ttl=54 time=2.90 ms
^C
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 2.781/2.837/2.898/0.047 ms
​

可以查看目标机器是否ping通

telnet
ubuntu@VM-0-3-ubuntu:~$ telnet 127.0.0.1 3000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
sfsdf
netstat
ubuntu@VM-0-3-ubuntu:~$ netstat -atn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN
tcp        0      0 172.17.0.1:53           0.0.0.0:*               LISTEN
tcp        0      0 172.16.0.3:53           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6010          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6011          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6012          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:6013          0.0.0.0:*               LISTEN
tcp        0      0 172.16.0.3:111          206.81.10.86:58812      ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:21580    ESTABLISHED
tcp        0      0 127.0.0.1:3000          127.0.0.1:58318         TIME_WAIT
tcp        0      0 172.16.0.3:22           183.198.11.196:21602    ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:22039    ESTABLISHED
tcp        0      0 172.16.0.3:39816        169.254.0.55:5574       ESTABLISHED
tcp        0      0 172.16.0.3:111          192.3.116.182:46844     ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:22025    ESTABLISHED
tcp        0      0 172.16.0.3:111          170.130.187.34:51001    ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:22506    ESTABLISHED
tcp        0      0 172.16.0.3:50948        169.254.0.138:8086      ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:22495    ESTABLISHED
tcp        0      0 172.16.0.3:111          164.90.208.105:46554    ESTABLISHED
tcp        0      0 172.16.0.3:22           183.198.11.196:22453    ESTABLISHED
tcp        0   3360 172.16.0.3:22           183.198.11.196:22438    ESTABLISHED
tcp6       0      0 :::111                  :::*                    LISTEN
tcp6       0      0 ::1:53                  :::*                    LISTEN
​
ubuntu@VM-0-3-ubuntu:~$ netstat -aun
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 172.17.0.1:53           0.0.0.0:*
udp        0      0 172.16.0.3:53           0.0.0.0:*
udp        0      0 127.0.0.1:53            0.0.0.0:*
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp        0      0 172.16.0.3:68           0.0.0.0:*
udp        0      0 0.0.0.0:111             0.0.0.0:*
udp        0      0 127.0.0.1:123           0.0.0.0:*
udp        0      0 172.16.0.3:123          0.0.0.0:*
udp6       0      0 fe80::5054:ff:fe9b:8:53 :::*
udp6       0      0 ::1:53                  :::*
udp6       0      0 :::111                  :::*
udp6       0      0 ::1:123                 :::*
udp6       0      0 fe80::5054:ff:fe9b::123 :::*
​
lsof
root@VM-0-3-ubuntu:/home/ubuntu# lsof -i -Pn | grep "3000"
epoll_ser  637850            root    3u  IPv4 48974473      0t0  TCP *:3000 (LISTEN)
epoll_ser  640784            root    3u  IPv4 48991331      0t0  TCP *:3000 (LISTEN)
​
nc
ubuntu@VM-0-3-ubuntu:~$ nc -v 127.0.0.1 3000 # tcp 连接上去
Connection to 127.0.0.1 3000 port [tcp/*] succeeded!
​
root@VM-0-3-ubuntu:/home/ubuntu/mybooksources-master/Chapter04/code# nc -v -l 127.0.0.1 3001  # 监听一个端口
Listening on localhost 3001
Connection received on localhost 39630
​
root@VM-0-3-ubuntu:/home/ubuntu/mybooksources-master/Chapter04/code# nc -v -l -u 127.0.0.1 3001  # 监听一个udp端口
Bound on localhost 3001
Connection received on localhost 50632
XXXXXdfdf
sdfsdf
​
ubuntu@VM-0-3-ubuntu:~$ nc -v -u 127.0.0.1 3001  # 连接udp
dfdf
Connection to 127.0.0.1 3001 port [udp/*] succeeded!
sdfsdf
​
curl
ubuntu@VM-0-3-ubuntu:~$ curl  www.baidu.com

 百度一下,你就知道          
新闻 hao123 地图 视频 贴吧 更多产品

关于百度 about Baidu

©2017 Baidu 使用百度前必读  意见反馈 京ICP证030173号 

tcpdump
root@VM-0-3-ubuntu:/home/ubuntu# tcpdump -i any "tcp port 3001"
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
19:56:12.928329 IP localhost.39946 > localhost.3001: Flags [S], seq 2726208034, win 65495, options [mss 65495,sackOK,TS val 2359419880 ecr 0,nop,wscale 7], length 0
19:56:12.928341 IP localhost.3001 > localhost.39946: Flags [S.], seq 3476933863, ack 2726208035, win 65483, options [mss 65495,sackOK,TS val 2359419880 ecr 2359419880,nop,wscale 7], length 0
19:56:12.928350 IP localhost.39946 > localhost.3001: Flags [.], ack 1, win 512, options [nop,nop,TS val 2359419880 ecr 2359419880], length 0
​
# 以上是抓包三次握手
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/724980.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号