Is it possible to add a static route to a gateway located in a differnet subnet

fedoraip-routing

I am trying this command:


route add -net 125.106.0.0 netmask 255.255.0.0 gw 105.101.67.70 dev eth0

105.101.67.70 is a public IP address of a VPN router gateway which located in a different subnet and connected through internet.

Result:


SIOCADDRT: No such process

Is it possible to route a traffic to external gateway ? or its required that the gateway should in the same network to enable static routing.

Any info or direction appreciated.

thanks.

Best Answer

What you're trying to do is endow the originating host with knowledge of how to route traffic after the next hop, which isn't strictly a routing table issue. As others have said, the best thing is to endow your next-hop route with knowledge of how to route to 125.106.0.0/16, and let the router sort it out.

If you really do want to do what you describe above, then this is called source routing, and it's by no means universally loved and honoured. If the devices in your routing path - specifically your next-hop router - will allow an LSRR packet, you may be able to pass this "where to go after next-hop router" information inside each packet to 125.106.0.0/16. Not having done this, I can't advise on how to construct such packets, but it will be an application issue.

Related Topic