LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2017, 01:31 AM   #1
kanak@tetcos.com
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Rep: Reputation: Disabled
Why static routes set using 'ip route add' and 'route add' commands are not used for routing packets within the same network?


I have three systems A,B,C. I want to configure A in such a way that all packets from A to C goes via B.

I tried:
1. ip route add 'ip of C' via 'ip of B'
2. route add -net 'net address' netmask gw 'ip of B'

These commands work initially when I try a ping or traceroute and expire after attempting ping twice or thrice.
 
Old 03-27-2017, 10:39 AM   #2
brebs
Member
 
Registered: May 2013
Posts: 89

Rep: Reputation: Disabled
If it's the same network, then the traffic will already be going to all 3 PCs.

Instead, use a VLAN.
 
1 members found this post helpful.
Old 03-27-2017, 12:59 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Actually, brebs, this isn't correct, and a VLAN won't have any effect on it.

Every computer sees only its own incoming traffic and obeys only its own rules. If the OP wishes for traffic to "go from A to B via C," this means that two routes must be established, on two machines:
  1. "A" must route the traffic to "B" ... designating "B" as a gateway. (Because "B" is not the final destination.)
  2. "B" must also know to route the traffic coming from "B," to "C."

There are two "hops" here, and each participant – each "hop" – must independently(!) know what to do with the packet. Packets do not carry any information whatsoever that says how they should be routed. Each and every participant makes its own independent routing decisions with regards to the traffic that is presented to it.

Furthermore, since traffic is two-way, the reply packets must also be able to make their way back home. Each "hop" computer, operating independently, must know how to do the right thing.

In this scenario, "B" is effectively a router that 'exposes' "C" to "A."
 
1 members found this post helpful.
Old 03-27-2017, 10:39 PM   #4
kanak@tetcos.com
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks brebs and sundialsvcs.
The problem here is that when I set B as gateway in A and C, it works perfectly fine in a windows system. All network traffic gets routed via B.
The same isn't happening in a PC with RHEL.
 
Old 03-30-2017, 01:18 AM   #5
kanak@tetcos.com
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
A's IP Address: 192.168.0.130
B's IP Address: 192.168.0.150
C's IP Address: 192.168.0.140

In Windows systems we achieve routing A's and B's traffic via C by running the following commands in A and C:
route delete 192.168.0.0
route add 192.168.0.0 mask 255.255.255.0 192.168.0.150

After executing the above commands, all network traffic from A and C will be routed via B.

I am looking for a linux equivalent of the same.
 
Old 04-01-2017, 06:11 AM   #6
kanak@tetcos.com
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi,

I was able to solve the problem by performing the following steps:

1. Static IP address was set.
2. Gateway IP was set to the IP of system B.
2. Automatic DNS was turned off.
3. Network was restarted.
4. Default route entry of the Network Address has to be deleted.

After doing these steps in Systems A and C all packets were getting routed via B.
 
Old 04-01-2017, 10:03 AM   #7
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Quote:
Originally Posted by kanak@tetcos.com View Post
Hi,

I was able to solve the problem by performing the following steps:

1. Static IP address was set.
2. Gateway IP was set to the IP of system B.
2. Automatic DNS was turned off.
3. Network was restarted.
4. Default route entry of the Network Address has to be deleted.

After doing these steps in Systems A and C all packets were getting routed via B.
Hi...

Glad you got it working. If you would, please mark this thread as "SOLVED" by clicking on "thread Tools" directly above your initial post. Thanks!

Also just as a suggestion, if your username is an email address, you might want to change it using the instructions at the top of the page here, lest your email inbox ends up with a boatload of SPAM in the very near future. You can find the "Contact Us" form here.

Regards...
 
Old 04-25-2017, 05:52 AM   #8
kanak@tetcos.com
LQ Newbie
 
Registered: Mar 2017
Posts: 5

Original Poster
Rep: Reputation: Disabled
Solved..!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
permanently add static route glock19 Linux - Networking 27 07-27-2015 04:59 PM
Add static route for Tunneled range? ne0shell Linux - Software 1 04-26-2013 12:06 AM
add static route with ip command mattholm Linux - Newbie 2 01-24-2013 05:11 PM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM
add a static route in Network init files Ghitza Linux - Networking 1 11-19-2004 05:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration