Add static route with destination
Q. I have 5 IP addresses from my provider, however, I can only access 1. When I try to access the others internally, they time out.
Another scenario: I would like to access a different subnet. (eg 192.168.0.0/24 from 192.168.1.0/24). How can this be done?
A. You need to add the gateway for particular IPs (or IP range) manually, to the routing table. (This exercise assumes that you are running a linux based router).
route -n
Will produce something like this:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 167.205.111.65 0.0.0.0 UG 100 0 0 eth0 167.205.111.64 0.0.0.0 255.255.255.224 U 0 0 0 eth0 172.17.0.0 0.0.0.0 255.255.255.0 U 0 0 0 vnet0
Assuming you have another IP address 134.107.51.216 you would like to route through 167.205.111.65, here's what to do:
route add -net 134.107.51.216 netmask 255.255.255.255 gw 167.205.111.65
This will produce the following route -n output:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 167.205.111.65 0.0.0.0 UG 100 0 0 eth0
167.205.111.64 0.0.0.0 255.255.255.224 U 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.255.0 U 0 0 0 vnet0
134.107.51.216 167.205.111.65 255.255.255.255 UGH 0 0 0 eth0
If you want to route an entire subnet (eg: 134.107.51.0/24), not just one IP address, you can do the following:
route add -net 134.107.51.0 netmask 255.255.255.0 gw 167.205.111.65
c9200l 24t 4g e
WS-C2960X-48LPS-L
ws-c2960x-48fpd-l
WS-C2960S-48TD-L
WS-C2960X-48LPD-L
Thanks for sharing this valuable information.