Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
eth0: 192.168.1.2 local ip
eth1: 59.144.124.58 internet static ip
eth2: 192.168.100.149 local ip
eth3: 10.32.138.40 local ip
in office we have our trading software which works on 10.32.138.1 as a gateway,if i didn't specify 10.32.138.1 as a gateway in the trading pc the trading software will not work, i want to do that when i give 10.32.138.40 as a gateway in trading pc it will to work.
Things i want to do without disturbing the internet which works on eth0 (localip) and eth1(static ip).
i want to do that when i specify 10.32.138.1 as a gatway in eth3 the nic will be work as a router but without disturbing the internet,because when i specify 10.32.138.1 as a gatway the internet get down and i cannot ping 192.168.1.2,when i delete the gateway from route command the internet works and i get ping response from 192.168.1.2
eth1 having gatway 59.144.124.1 for my internet i had defined with route command and i don't want to delete gateway,if i did the internet will not work so i don't want to touch this interface.
eth3 i want to define 10.32.138.1 as a gateway,and also i want to route internet to 10.32.138.40 which comes from eth1 and eth0 interface.it just like the matter of multiple nics with multiple gatways forget about eth2 nic.so please help me to sort out this matter
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660
Rep:
You can't have multiple default routes unless you use ip2 to do policy-based routing. Otherwise there is just one default route that will take precedence. You can have as many static routes as you like, though. So you can say the route to a certain subnet goes to a certain gateway. You can use this to specify how to get to subnets that aren't directly connected.
Are you trying to say that 10.32.138.1 is some other box (firewall or router) that has access to the trading network? You need to get traffic from 10.32.138/24 to there, but you want it to go through the proxy first? Or do you really just want the trading software to go through your proxy and then out to the Internet? I'm not very clear what you're trying to accomplish.
If you're trying to accomplish the latter, you'll need to use source-based routing, unless the trading software is always trying to go to a certain subnet that none of your other traffic goes to. In that case you could just set a static route for that subnet with a gateway of 10.32.138.1.
eth0 192.168.1.2----- eth1 59.144.124.58 this 2 nics used for internet
eth2 192.168.100.145-------forget about this nic,because my question is about eth3 nic--------10.32.138.40. we have one router in office which is having ipaddress 10.32.138.1,we have to define this router's ip address in every pc as a gateway,if we don't define the router's ip address in the pc my trading software will not work.now i want to say that in eth3 i want to define the route's ip as a gateway it will look like this
Perhaps it would be best if you think of routing as a decision making process: when I (a NIC) get a packet, which Interface (and hence wire) does my routing table tell me to place the packet.
And for "default route", think of it as "when there is no other match in the routing table, which interface shall the packet be placed on so that it is picked up by a directly connected routing station".
Draw yourself a picture, of your systems and your 4-NIC'd system, and ask those questions at each station, both to and from each interface.
To do that you'll need to use the ip2 route/rule commands. The lartc documenation is a good read on how to do this, http://www.lartc.org
Essentially you need to add a new table to rt_table and then specify a default route for that table and what ips should use that table for routing, and any other routes you'd like for that table.
so for example if your table was trading
ip route add default via 10.32.138.1 table trading
ip route add 10.32.138.0/24 dev eth3 src 10.32.138.40 table trading
ip rule add from 10.32.138.40 table trading
The still fuzzy part is if you are running the trading app on that box it won't necessarily route out that interface, you'd need to know where it was trying to go and add another ip route/rule or bind the app to that interface. Say it was trying to connect to the trading server at 172.16.0.1, then you'd need something like this:
ip rule add to 172.16.0.1 table trading
And once you are that far you can see that if you know where the trading app is going, you might be able to skip all that and just add a normal route that says route add 172.16.0.1 gw 10.32.138.1 avoiding all the other pain.
I do think however that if you are using that box as a router that you'll want to setup ip2 stuff for each of the interfaces its amazingly powerful stuff and well worth learning.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.