netsh interface是Windows操作系统中的一个命令行工具,用于管理网络接口和配置网络设置。它允许用户在命令提示符下执行各种网络相关任务。以下是一些常用的netsh interface子命令及其功能:

  • 查看可用的网络接口:
netsh interface show interface
  • 查看网络接口的详细信息:
netsh interface show interface <InterfaceName>
  • 启用指定的网络接口:
netsh interface set interface <InterfaceName> admin=ENABLED
  • 禁用指定的网络接口:
netsh interface set interface <InterfaceName> admin=DISABLED
  • 设置网络接口的IPv4地址和子网掩码:
netsh interface ipv4 set address <InterfaceName> static <IPAddress> <SubnetMask>
  • 设置网络接口的IPv6地址:
netsh interface ipv6 add address <InterfaceName> <IPAddress>
  • 启用或禁用网络接口上的DHCP:
netsh interface ipv4 set address <InterfaceName> dhcp
netsh interface ipv4 set address <InterfaceName> dhcp enabled=no
  • 配置网络接口的默认网关:
netsh interface ipv4 set address <InterfaceName> gateway=<GatewayIPAddress> metric=<Metric>
  • 设置DNS服务器地址:
netsh interface ipv4 set dns <InterfaceName> static <DNSIPAddress>
  • 查看网络接口的IP配置信息:
netsh interface ipv4 show config <InterfaceName>
netsh interface ipv6 show config <InterfaceName>

请注意,上述命令中的<InterfaceName>应替换为实际的网络接口名称,例如"Ethernet"、"Wi-Fi"等。另外,一些命令可能需要管理员权限才能执行成功。使用netsh interface命令时,请谨慎操作,以免造成网络设置的错误或意外更改。建议在使用前先备份当前的网络配置。

Windows端口转发,可以将目标服务通过本地地址和端口开放出来。

1、新增

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=1433 connectaddress=IP_OR_DOMAIN_NAME connectport=1433

2、查看

netsh interface portproxy show v4tov4

3、删除

netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport=1433

注意,要关闭本地防火墙或者开放指定端口。

4、其他命令

#查看是否启动成功
netstat -ano | find listenport
 #显示系统中的转发规则列表
netsh interface portproxy show all
#查看portproxy设置
netsh interface portproxy dump 
 #清除所有端口转发规则
netsh interface portproxy reset