Windows 系统中的网络接口
Windows 操作系统将其所有的网络接口,划分为三大种类,
| 种类 | 说明 |
|---|---|
| Public | 不可信网络,如在咖啡厅的 WiFi |
| Private | 可信网络,如家中的 LAN |
| Domain Authenticated | 由活动目录(Active Directory,AD)的域控制器(Domain Controller,DC)认证过的机器组成的网络 |
这三大种类,也称为“网络轮廓(network profiles)”或“防火墙轮廓(firewall profiles)”。
profile 在 Windows 操作系统中文版翻译中译为“配置”,如
控制面板–>高级安全 Windows Defender 防火墙–>入站规则/出站规则中
Windows 系统中任何一个网络接口,都会被归为上述三类接口之一。当新增一个网络接口时,WIndows 会利用 Network Location Awareness(NLA)服务探测这个接口是否可以连接上一个本地的 AD DC,或者连接上某个公共的 Internet 服务。如果找到了一个 DC,WIndows 系统将这个接口被归类为 Domain 类;其他的大多数情况,系统将这个接口归为 Public 类。
网络接口轮廓管理指令
Get-NetConnectionProfile / Set-NetConnectionProfile
设置网络接口 wg0 为 Private 类接口
Set-NetConnectionProfile -InterfaceAlias wg0 -NetworkCategory Private
网络接口管理指令
Get-NetIPInterface / Set-NetIPInterface
查看网络接口的路由转发
Get-NetIPInterface | Select IfIndex, InterfaceAlias, AddressFamily, Forwarding | Sort-Object -Property IfIndex | Format-Table
设置网络接口 Ethernet 的路由转发
Set-NetIPInterface -InterfaceAlias Ethernet -Forwarding Enabled
上述指令对 IPv4 和 IPv6 都开启了路由转发,如果对 IPv4 和 IPv6 路由转发精准设置,可使用 netsh 命令,
netsh interface ipv4 set interface Ethernet forwarding=enabled
netsh interface ipv6 set interface Ethernet forwarding=enabled
路由管理
显示 IPv4 路由表
route print -4
软件端口管理
显示监听端口
netstat -ano | findstr "TCP" | findstr "LISTENING"
Windows 防火墙 – WDF
Windows 操作系统自带防火墙 Windows Defender Firewall,简称 WDF。
- 与其他系统防火墙一样,默认情况下,Windows 防火墙会拒绝所有入站连接(inbound connections),允许所有的出站连接(outbound connections);
- Windows 的网络接口分为三类,防火墙会为三类接口设置不同的防火墙轮廓/配置
- Domain Profile
- Private Profile
- Public Profile