netsh 是 windows 平台网络管理命令

防火墙设置

开启防火墙

1
2
3
4
5
6
sc config mpsdrv start= auto
sc config mpssvc start= auto
sc start mpsdrv
sc start mpssvc

netsh advfirewall set allprofiles state on

规则配置

1
2
3
4
5
6
7
8
:: 拒绝指定IP访问指定端口
netsh advfirewall firewall add rule name=BlockRTX dir=in protocol=tcp localport=8000 action=block enable=yes remoteip=192.168.5.2

:: 开放一个端口
netsh advfirewall firewall add rule name="445" protocol=TCP dir=in localport=445 action=allow

:: windows xp 使用
netsh firewall set portopening TCP 445 ENABLE

防火墙配置

1
2
3
4
5
:: 关闭防火墙
netsh firewall set opmode mode=disable

:: 防火墙恢复默认配置
netsh firewall reset

修改网络设置

修改 ip、dns 等

1
2
3
4
5
6
7
8
# STATIC
netsh interface ip set address "以太网" static 192.168.8.88 255.255.252.0 192.168.8.3
netsh interface ip set dns "以太网" static 114.114.114.114
netsh interface ip add dns "以太网" 114.114.115.115

# DHCP
netsh interface ip set address "以太网" dhcp
netsh interface ip set dns "以太网" dhcp