In the Linux system, we can use bellow command to enable packets forwarding:

~ # sysctl net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

but how can I realize the same function in Windows?

I use Windows Server 2008 R2.


2 Answers 2


Try to go to the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters. If not already there, create a new REG_DWORD value named IPEnableRouter. Set IPEnableRouter to 1 and reboot. Packet forwarding should now be enabled.

To add static routes use the route command.


If you want to enable forwarding for a specific interface or all interfaces you can do it easily from PowerShell, no reboot required. (NOTE: be sure to run as an Administrator if you want to change the setting)

To look at the status of forwarding for all interfaces you can execute the following:

Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table

This will provide a nice table showing all the interfaces and their current forwarding configuration.

Then if you want to enable forwarding on one you can run:

Set-NetIPInterface -ifindex <required interface index from table> -Forwarding Enabled

If you want to enable it for all interfaces simply run:

Set-NetIPInterface -Forwarding Enabled

Then if you want to disable it again simply replace "Enabled" with "Disabled".

And remember to enable Routing and Remote Access service (By default is disabled) by running:

Set-Service RemoteAccess -StartupType Automatic; Start-Service RemoteAccess
  • When I run the Get-NetIPInterface in PowerShell, I get cannot recognition command Error.
    – aircraft
    Sep 3, 2018 at 2:57
  • Try running: Import-Module NetTCPIP
    – Alex Moore
    Sep 3, 2018 at 6:11
  • Let me know if that works and I'll update the answer
    – Alex Moore
    Sep 3, 2018 at 6:33
  • PS C:\Users\Administrator> Import-Module NetTCPIP Import-Module : Can not load module“NetTCPIP”,because can not find it...
    – aircraft
    Sep 3, 2018 at 6:47
  • What version of Windows?
    – Alex Moore
    Sep 3, 2018 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .