一,网络命令⭐️⭐️⭐️⭐️⭐️⭐️
1,ping命令
[root@gsf ~]# ping www.baidu.com
-c 数字 #指定ping的次数
-i 数字 #指定多少秒ping一次
-f #秒ping一般与-c一起用
[root@gsf ~]# ping -c 1000 -f www.baidu.com
PING www.a.shifen.com (110.242.68.4) 56(84) bytes of data.
--- www.a.shifen.com ping statistics ---
1000 packets transmitted, 1000 received, 0% packet loss, time 11106ms
rtt min/avg/max/mdev = 10.197/11.826/19.062/1.300 ms, pipe 2, ipg/ewma 11.117/12.316 ms
2,telnet命令
#探测目标主机的端口,对应服务与其版本;
[root@gsf ~]# telnet 10.0.0.200 22
Trying 10.0.0.200...
Connected to 10.0.0.200.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4
Protocol mismatch.
3,nmap扫描命令
[root@gsf ~]# nmap -p 80,8080,443,22 10.0.0.200
Starting Nmap 6.40 ( http://nmap.org ) at 2024-10-14 17:43 CST
Nmap scan report for 10.0.0.200
Host is up (0.000037s latency).
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp closed https
8080/tcp closed http-proxy
##############
[root@gsf ~]# nmap -p 0-65535 10.0.0.200
Starting Nmap 6.40 ( http://nmap.org ) at 2024-10-14 17:44 CST
Nmap scan report for 10.0.0.200
Host is up (0.0000040s latency).
Not shown: 65534 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
4,wget下载
wget 链接地址
[root@gsf ~]# wget https://www.gsfedu.com/media/article/2021/11/24/1.png
#指定下载到一个目录下;
wget -O /tmp/1.png https://www.gsfedu.com/media/article/2021/11/24/1.png
5,netstat/ss查本机端口
netstat -tnulp
ss -tnulp
##############
-l #只看listen状态的服务;(TCP11中状态)
-n #用数字的方式显示服务;
-t #TCP链接
-u #UDP链接
-p #显示进程名称
##################
netstat -an
- a #显示所有连接中的(socket)信息
- n #以数字(端口号)的方式显示
netstat -r
- r #显示系统路由表
[root@gsf ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default gateway 0.0.0.0 UG 0 0 0 ens33
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
6,追踪路由过程
#windows命令
C:\Users\62608>tracert -4 www.baidu.com
#linux命令
[root@gsf ~]# yum -y install traceroute
[root@gsf ~]# traceroute www.baidu.com
7,tcpdump抓包工具
[root@gsf ~]# yum -y install tcpdump
tcpdump -i ens33 #指定网卡
-nn #以数字的方式显示;
-X #把协议头与内容原原本本的显示出来(以16进制ascll码的形式显示)
-c 数字 #抓几个包;
-w 文件名 #将抓包信息写入文件;
-r 文件名 #读文件
################
[root@gsf ~]# tcpdump -i ens33 -nn -X -c5 'port 22' -w 1.txt
......
[root@gsf ~]# ll
.....
-rw-r--r-- 1 tcpdump tcpdump 592 10月 14 18:07 1.txt
[root@gsf ~]# tcpdump -r 1.txt
reading from file 1.txt, link-type EN10MB (Ethernet)
18:07:29.739441 IP girl.ssh > 10.0.0.1.50256: Flags [P.], seq 1458078027:1458078175, ack 2970753762, win 273, length 148
18:07:29.784597 IP 10.0.0.1.50256 > girl.ssh: Flags [.], ack 148, win 4096, length 0
18:07:46.474322 IP 10.0.0.1.63728 > girl.ssh: Flags [P.], seq 1328700290:1328700342, ack 3557189058, win 511, length 52
18:07:46.474347 IP girl.ssh > 10.0.0.1.63728: Flags [.], ack 52, win 251, length 0
18:07:52.848783 IP 10.0.0.1.65515 > girl.ssh: Flags [S], seq 3102021791, win 64240, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0
8,route查看本机路由表
[root@gsf ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.2 0.0.0.0 UG 100 0 0 ens33
10.0.0.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33