Related Items  

Linux and Windows IT Support  

We make IT Support easy!

Windows, Apple and Linux IT support and services.

Login or Register  

If you wish to contribute an article, please login or register.

Add static route with destination

PrintE-mail

linux 128Q. 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

 

Comments (1)
Route add
1 Thursday, 23 February 2017 04:57
Aslam Khan
Good solutions

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2017 Virtual Helpme | IT Services Catered to Your Business | Original Template: Allrounder
-->