ubuntu@VM-0-3-ubuntu:~$ ifconfigdocker0: flags=4099
可以方便的查看本机的几个网卡
pingubuntu@VM-0-3-ubuntu:~$ ping www.baidu.comPING 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 ms64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=2 ttl=54 time=2.79 ms64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=3 ttl=54 time=2.78 ms64 bytes from 14.215.177.39 (14.215.177.39): icmp_seq=4 ttl=54 time=2.84 ms64 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 4006msrtt min/avg/max/mdev = 2.781/2.837/2.898/0.047 ms
可以查看目标机器是否ping通
telnetubuntu@VM-0-3-ubuntu:~$ telnet 127.0.0.1 3000Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is '^]'.sfsdf
netstatubuntu@VM-0-3-ubuntu:~$ netstat -atnActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 0.0.0.0:111 0.0.0.0:* LISTENtcp 0 0 172.17.0.1:53 0.0.0.0:* LISTENtcp 0 0 172.16.0.3:53 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:53 0.0.0.0:* LISTENtcp 0 0 127.0.0.53:53 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:953 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:6012 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:6013 0.0.0.0:* LISTENtcp 0 0 172.16.0.3:111 206.81.10.86:58812 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:21580 ESTABLISHEDtcp 0 0 127.0.0.1:3000 127.0.0.1:58318 TIME_WAITtcp 0 0 172.16.0.3:22 183.198.11.196:21602 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:22039 ESTABLISHEDtcp 0 0 172.16.0.3:39816 169.254.0.55:5574 ESTABLISHEDtcp 0 0 172.16.0.3:111 192.3.116.182:46844 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:22025 ESTABLISHEDtcp 0 0 172.16.0.3:111 170.130.187.34:51001 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:22506 ESTABLISHEDtcp 0 0 172.16.0.3:50948 169.254.0.138:8086 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:22495 ESTABLISHEDtcp 0 0 172.16.0.3:111 164.90.208.105:46554 ESTABLISHEDtcp 0 0 172.16.0.3:22 183.198.11.196:22453 ESTABLISHEDtcp 0 3360 172.16.0.3:22 183.198.11.196:22438 ESTABLISHEDtcp6 0 0 :::111 :::* LISTENtcp6 0 0 ::1:53 :::* LISTEN
ubuntu@VM-0-3-ubuntu:~$ netstat -aunActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address Stateudp 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 :::*
lsofroot@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)
ncubuntu@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 3001Connection received on localhost 39630root@VM-0-3-ubuntu:/home/ubuntu/mybooksources-master/Chapter04/code# nc -v -l -u 127.0.0.1 3001 # 监听一个udp端口Bound on localhost 3001Connection received on localhost 50632XXXXXdfdfsdfsdfubuntu@VM-0-3-ubuntu:~$ nc -v -u 127.0.0.1 3001 # 连接udpdfdfConnection to 127.0.0.1 3001 port [udp/*] succeeded!sdfsdf
curlubuntu@VM-0-3-ubuntu:~$ curl www.baidu.com 关于百度 about Baidu ©2017Baidu使用百度前必读 意见反馈京ICP证030173号
root@VM-0-3-ubuntu:/home/ubuntu# tcpdump -i any "tcp port 3001"tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes19: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 019: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 019:56:12.928350 IP localhost.39946 > localhost.3001: Flags [.], ack 1, win 512, options [nop,nop,TS val 2359419880 ecr 2359419880], length 0# 以上是抓包三次握手