Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

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 (2)
IT INNOVATION INC
2 Thursday, 15 December 2022 10:59
IT INNOVATION INC
As for how much time it takes, it really depends. Some days I can spend hours writing and researching, and other days I might only spend a few minutes. It all depends on my mood and inspiration.
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.
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 - 2024 Virtual Helpme | Managed IT Solutions Specialized for Your Business | Original Template: Allrounder