Windows 网络管理命令

时间:2021-05-04 15:37:20   收藏:0   阅读:0

本文列出一些常用的 Windows 网络管理命令。

ping

ping: 测试网络连接情况

$ ping 192.168.20.8 -n 3

Pinging 192.168.20.8 with 32 bytes of data:
Reply from 192.168.20.8: bytes=32 time<1ms TTL=64
Reply from 192.168.20.8: bytes=32 time<1ms TTL=64
Reply from 192.168.20.8: bytes=32 time<1ms TTL=64

Ping statistics for 192.168.20.8:
    Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

网络信息查询

netstat

netstat: 协议统计和当前 TCP/IP 网络连接

$ netstat -ano -p tcp
Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:21             0.0.0.0:0              LISTENING       4896
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       1032
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:902            0.0.0.0:0              LISTENING       10388
  TCP    0.0.0.0:912            0.0.0.0:0              LISTENING       10388
  TCP    0.0.0.0:1080           0.0.0.0:0              LISTENING       11476
  TCP    0.0.0.0:2425           0.0.0.0:0              LISTENING       7728
  TCP    0.0.0.0:5040           0.0.0.0:0              LISTENING       7940
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING       4

网卡信息

$ ipconfig
$ ipconfig /all
$ netsh interface ipv4 show config
$ netsh interface ipv6 show config
$ wmic nic list brief

路由配置

route add [Destination] mask [netmask] [gw] metric [测量值]

# ipv4
$ route -p add 23.23.23.0 mask 255.255.255.0 192.168.97.60
route delete 23.23.23.0
# ipv6
$ netsh interface ipv6 add/del route 2001::/64 "Local Area Connection 2" 2001::2

查看路由表

$ netstat -r
$ route print
$ route print -4
$ route print -6
$ netsh interface ipv4 show route
$ netsh interface ipv6 show route

禁用启用网卡

$ netsh interface set interface eth0 disabled # 禁用网卡
$ netsh interface set interface name="接口名称" admin=DISABLE

$ netsh interface set interface eth0 enabled #启用网卡
$ netsh interface set interface name="接口名称" admin=ENABLE

$ netsh interface ipv6 set interface name="接口名称"  disable/enable

$ netsh interface show interface #显示接口

通过python脚本自动化控制:

import os
os.popen(‘netsh interface set interface name="接口名称" admin=DISABLE‘)

释放、更新地址

# ipv4
$ ipconfig /release
$ ipconfig /renew
# ipv6
$ ipconfig /release6
$ ipconfig /renew6

添加、删除IP地址

# ipv4
$ netsh interface ip add address "本地连接" 192.168.1.100 255.255.255.0
$ netsh interface ip delete address "本地连接" 192.168.1.100
## 设置静态IP地址
$ netsh interface ip set address name="eth1" source=static address=192.168.5.125 mask=255.255.255.0

# ipv6
$ netsh interface ipv6 delete address 本地连接 2001::1
$ netsh interface ipv6 add/del address 本地连接 2001::1
--THE END--

欢迎关注公众号:「测试开发小记」及时接收最新技术文章!

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!