查看生效的ip信息網絡
[root@local ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255 inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet) RX packets 7492 bytes 625846 (611.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3334 bytes 451391 (440.8 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 0 (Local Loopback) RX packets 12 bytes 1020 (1020.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 1020 (1020.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:8c:58:59 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
關閉和啓動網卡ssh
[root@local ~]# ifdown lo [root@local ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255 inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet) RX packets 7600 bytes 634935 (620.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3384 bytes 457849 (447.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:8c:58:59 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
[root@local ~]# ifup lo [root@local ~]# ifconfig eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.70.77 netmask 255.255.255.0 broadcast 192.168.70.255 inet6 fe80::20c:29ff:fe6e:b72b prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6e:b7:2b txqueuelen 1000 (Ethernet) RX packets 7647 bytes 638881 (623.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3416 bytes 462387 (451.5 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 0 (Local Loopback) RX packets 12 bytes 1020 (1020.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 1020 (1020.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:8c:58:59 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
查看網絡狀態tcp
-t 列出tcp協議端口oop
-u 列出udp協議端口spa
-n 不使用域名與服務名,使用IP和端口code
-l 列出監聽狀態的網絡服務server
-a 列出全部的網絡鏈接blog
-r 路由信息進程
-p 列出pid,進程idip
[root@local ~]# netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.70.70 0.0.0.0 UG 0 0 0 eno16777736 192.168.70.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16777736 [root@local ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.70.70 0.0.0.0 UG 100 0 0 eno16777736 192.168.70.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736 [root@local ~]# netstat -anp|grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1185/sshd tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED 2436/sshd: root@pts tcp6 0 0 :::22 :::* LISTEN 1185/sshd [root@local ~]# netstat -an|grep :22 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED tcp6 0 0 :::22 :::* LISTEN [root@local ~]# netstat -tunl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN udp 0 0 192.168.122.1:53 0.0.0.0:* udp 0 0 0.0.0.0:67 0.0.0.0:* udp 0 0 0.0.0.0:5353 0.0.0.0:* udp 0 0 127.0.0.1:323 0.0.0.0:* udp 0 0 0.0.0.0:46466 0.0.0.0:* udp6 0 0 ::1:323 :::*
經過這條指令查看當前計算機開啓了哪些服務。
[root@local ~]# netstat -an|grep ESTABLISHED tcp 0 52 192.168.70.77:22 192.168.70.33:58840 ESTABLISHED
查看正在鏈接個人計算機。
[root@local ~]# netstat -an|grep ESTABLISHED |wc -l 1
查看DNS
[root@local ~]# nslookup www.qq.com Server: 114.114.114.114 Address: 114.114.114.114#53 Non-authoritative answer: Name: www.qq.com Address: 180.96.86.192 [root@local ~]# ping www.qq.com PING www.qq.com (180.96.86.192) 56(84) bytes of data. 64 bytes from 180.96.86.192: icmp_seq=1 ttl=54 time=9.60 ms 64 bytes from 180.96.86.192: icmp_seq=2 ttl=54 time=9.33 ms
跟蹤查看路由命令
[root@local ~]# traceroute www.baidu.com traceroute to www.baidu.com (180.97.33.107), 30 hops max, 60 byte packets 1 192.168.70.70 (192.168.70.70) 0.275 ms 0.274 ms 0.223 ms 2 192.168.1.1 (192.168.1.1) 0.555 ms 0.604 ms 0.534 ms 3 100.73.0.1 (100.73.0.1) 3.010 ms 3.316 ms 3.267 ms 4 222.187.235.217 (222.187.235.217) 2.718 ms 2.646 ms 2.585 ms 5 222.187.235.105 (222.187.235.105) 13.826 ms 13.559 ms 13.826 ms 6 202.102.73.122 (202.102.73.122) 16.276 ms 202.102.73.126 (202.102.73.126) 19.856 ms 202.102.69.186 (202.102.69.186) 13.546 ms 7 * * * 8 180.97.32.130 (180.97.32.130) 13.049 ms 180.97.32.26 (180.97.32.26) 139.445 ms 180.97.32.2 (180.97.32.2) 10.769 ms 9 * * * [root@local ~]# ping www.baidu.com PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data. 64 bytes from 180.97.33.107: icmp_seq=1 ttl=55 time=9.25 ms 64 bytes from 180.97.33.107: icmp_seq=2 ttl=55 time=9.55 ms 64 bytes from 180.97.33.107: icmp_seq=3 ttl=55 time=9.30 ms
下載命令
抓包命令
-i 指定監聽的網卡
-nn 將數據包中的域名與服務轉爲ip和端口
-X 以16進制和ASCII碼顯示數據包內容
prot指定監聽的端口
[root@local 桌面]# tcpdump -i eth0 -nnX port 22
遠程上傳或者下載
[root@localhost ~]# scp -r testscp/ root@192.168.70.77:/root The authenticity of host '192.168.70.77 (192.168.70.77)' can't be established. RSA key fingerprint is c1:d1:80:44:94:0b:e2:fb:b4:82:20:79:5f:94:5f:41. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.70.77' (RSA) to the list of known hosts. root@192.168.70.77's password: hello
這個是上傳
[root@localhost testscp]# scp -r root@192.168.70.77:/root/testscp /root root@192.168.70.77's password: hello 100% 10 0.0KB/s 00:00 world 100% 12 0.0KB/s 00:00
這個是下載