在Linux系统中,我们可以使用bellow命令开启报文转发:
~ # sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
Run Code Online (Sandbox Code Playgroud)
但是如何在 Windows 中实现相同的功能呢?
我用Windows Server 2008 R2
.
Ale*_*ore 11
如果要为特定接口或所有接口启用转发,您可以从 PowerShell 轻松完成,无需重新启动。(注意:如果要更改设置,请务必以管理员身份运行)
要查看所有接口的转发状态,您可以执行以下操作:
Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table
Run Code Online (Sandbox Code Playgroud)
这将提供一个很好的表格,显示所有接口及其当前的转发配置。
然后,如果您想在一个上启用转发,您可以运行:
Set-NetIPInterface -ifindex <required interface index from table> -Forwarding Enabled
Run Code Online (Sandbox Code Playgroud)
如果要为所有接口启用它,只需运行:
Set-NetIPInterface -Forwarding Enabled
Run Code Online (Sandbox Code Playgroud)
然后,如果您想再次禁用它,只需将“启用”替换为“禁用”。
并记住通过运行启用路由和远程访问服务(默认情况下是禁用的):
Set-Service RemoteAccess -StartupType Automatic; Start-Service RemoteAccess
Run Code Online (Sandbox Code Playgroud)
小智 10
尝试转到注册表项HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
。如果尚不存在,请创建一个REG_DWORD
名为 的新值IPEnableRouter
。设置IPEnableRouter
为1
并重新启动。现在应该启用数据包转发。
要添加静态路由,请使用该route
命令。
归档时间: |
|
查看次数: |
22787 次 |
最近记录: |