There is a device behind the router, say, and ssh enabled on port 22. Gw address specified as in the route table.

And there is a router,

I'm creating a port forward rule to access the device from wan.

source - port - destination - port
0      - 22   - - 22

So, anyone coming from wan on port 22, can access the device.

However, when I remove the gw address ( from the route table of the device, then port forward is not working anymore.

What I don't understand is here;

  • In local network router and the device can reach each other. If there is an ssh client app in the router, I can connect to the device whether there is a gateway is set in the device or not. So, local network is working on ETH0 interface of the router.
  • Port forward should route all my packages coming from WAN interface on specific port to the specific port of specific IP which resides behind the LAN interface.
  • Request is coming from the WAN, which means communication is started by a remote device. And in this case, local device should has nothing to do with the gateway address, because it just responding a request which is coming from the LAN interface of the gw.
  • When the device sends the response, the router should send it to the remote client.

In this case, I don't see the necessity of entering the gw address to the device.

At which point am I mistaken?

1 Answer 1


Port forwarding change the destination IP address, but leave the source IP address unchanged.

When your internal SSH machine reply to the original sender, it takes the source IP address of the packet it received and set this address as the destination IP address of its reply.

Without a gateway it doesn't know where to send the reply and so the communication fail.

  • Thanks. And what about the pptp vpn connection? if there is a pptp vpn server in the router and if I connect it, do I still need to set gw in the device to access it? Dec 6, 2017 at 12:34
  • Any device in your local network need a route (generally in the form of a default gateway) to be able to speak to any other device that is not in the same network.
    – JFL
    Dec 6, 2017 at 12:54
  • But when I connect to VPN doesn't it mimic the same network? Dec 6, 2017 at 14:09
  • It depends on the pptp server configuration.
    – JFL
    Dec 6, 2017 at 14:14
  • What is that configuration and can you refer me any documents/links to go further? Thanks. Dec 7, 2017 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.