linux 网络命令

1.ping命令 后面-c参数 表示要connect 平链接的次数

ping -c 10 127.0.0.1

表示要ping10次后停止

2. nslookup命令查看域名解析的IP是地址是多少

daokr@DK:/etc$ nslookup baidu.com
Server:        127.0.1.1
Address:    127.0.1.1#53

Non-authoritative answer:
Name:    baidu.com
Address: 220.181.57.216
Name:    baidu.com
Address: 111.13.101.208

daokr@DK:/etc$ ping baidu.com
PING baidu.com (220.181.57.216) 56(84) bytes of data.
64 bytes from 220.181.57.216: icmp_seq=1 ttl=128 time=39.0 ms
64 bytes from 220.181.57.216: icmp_seq=2 ttl=128 time=95.6 ms
64 bytes from 220.181.57.216: icmp_seq=3 ttl=128 time=37.1 ms
^X64 bytes from 220.181.57.216: icmp_seq=4 ttl=128 time=37.1 ms

3.route路由命令来查看路由映射信息

参数:-n 表示查看缓存于主机的路由信息

daokr@DK:/etc$ route -n
内核 IP 路由表
目标            网关            子网掩码        标志  跃点   引用  使用 接口
0.0.0.0         192.168.10.254  0.0.0.0         UG    100    0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 ens33
192.168.10.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33

添加默认网关:

route add default gw 192.168.10.255

删除网关:

route del default gw 192.168.10.255

4.网络统计信息查看命令:netstat

查看当前的网络统计信息命令:

netstat  -a  用于查看包含监听信息的所有网络统计信息

-r 查看路由可以和 -a一起使用

daokr@DK:/etc$ netstat -ar
内核 IP 路由表
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.10.254  0.0.0.0         UG        0 0          0 ens33
link-local      *               255.255.0.0     U         0 0          0 ens33
192.168.10.0    *               255.255.255.0   U         0 0          0 ens33

 

netstat  -t  用于显示tcp协议的相关信息 -t

daokr@DK:/etc$ netstat -t
激活Internet连接 (w/o 服务器)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 192.168.10.168:ssh      192.168.10.1:60139      ESTABLISHED
tcp        1      0 192.168.10.168:52724    123.150.8.42:8001       CLOSE_WAIT 
tcp        1      0 192.168.10.168:52722    123.150.8.42:8001       CLOSE_WAIT 

 

posted @ 2018-03-31 17:13  王默默  阅读(844)  评论(0编辑  收藏  举报