How to add a static route to external gateway(external IP)

fedoraroute

I am having an issue with setting up a static route in Fedora.

I need to route some traffic to an external gateway(105.101.67.70 – public IP address of a VPN router). Any request sent to 125.106.67.70 needs to be routed to VPN router gateway 105.101.67.70 and the router will connect it to a VPN network. Fedore server, VPN router and the VPN network are located in different locations and all connected through internet.

Tried following steps in command line:

route add -net 125.106.0.0 netmask 255.255.0.0 gw 105.101.67.70 dev eth0

The result:

SIOCADDRT: No such process

Route info:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.250.0   *               255.255.255.0   U     0      0        0 eth0
link-local      *               255.255.0.0     U     0      0        0 eth0
default         192.168.250.241 0.0.0.0         UG    0      0        0 eth0

Best Answer

This almost certainly means that you don't have a route for YYY.YYY.YYY.YYY (i.e. 105.101.67.70).

Given lack of detail, I am going to assume you don't have anything unusual going on. Basically your route statement is never going to work given the addresses you have posted currently. To add a route the gateway must be on a network that is directly connected, and given your current route table, it means the gateway for that route must be an address on the network 192.168.250.0/24.

To use a gateway your box must be able to directly send the packets to the gateway, on Ethernet, that means your computer must be able to successfully receive an ARP response for YYY.YYY.YYY.YYY. That can only really happen if YYY.YYY.YYY.YYY is on a subnet that is locally connected. By locally connected I mean there is no layer 3 devices between your box and YYY.YYY.YYY.YYY. If YYY.YYY.YYY.YYY is not local, then you are almost certainly trying to add a route on the wrong device, and you should be adding it on the router that is directly connected to YYY.YYY.YYY.YYY.

Related Topic