How can I enable packet forwarding on Windows?

Solution 1:

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

Solution 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.

Tags:

Windows