How to add multiple gateway in /etc/sysconfig/network in Linux ?

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi guys,

I got an existing GATEWAY = 192.1.1.1 in my /etc/sysconfig/network. How can I add one more gateway, which is 192.1.1.100 ? Thanks !
 

Ender78

Senior member
Feb 24, 2001
413
0
0
What are you trying to accomplish here ? Is .100 another NAT device ? This type of setup could really cause a lot of problems. What type of load balancing are you trying to accomplish?
 

kmthien

Senior member
Oct 8, 2002
363
0
0
192.1.1.1 is the gateway which link back to my main office and 192.1.1.100 is the gateway to link to partner company !
 

Buddha Bart

Diamond Member
Oct 11, 1999
3,064
0
0
192.1.1.1 is the gateway which link back to my main office and 192.1.1.100
They look like they're both on the same subnet (assuming /24), in which case I'll also assume they go out the same interface on your PC. In which case, everything should be taken care of for you upstream.

bart
 

cmetz

Platinum Member
Nov 13, 2001
2,296
0
0
Slighlty oversimplifying, you can't have two "gateways" (default routes). What you need is for a default route to point to one of them, and more-specfic subnet route(s) to point to the other one.

The simple way is to just put 'em in your /etc/rc.local:

route add -net 1.2.3.0 netmask 255.255.255.0 gw 192.1.1.100

will send traffic destined to 1.2.3.0/24 to 192.1.1.100 instead, while everything else goes out the default route to 192.1.1.1.
 

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi,

U means 1.2.3.0 is my linux server ? After modifying my rc.local, do I need to restart the server or which server to restart ? Thanks

kmthien
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Do you have 2 routers on your LAN?

one with the port address of 192.1.1.1 and another router with the port labeled 192.1.1.100? and both ports are Attached to your LAN and both routers go to entirely different places???.... (Generally it's the Router port that is the "gateway".)Thats pretty weird...

but read "man route", see if that helps any, but I am not sure what your talking about... So if you can please discribe your LAN in better terms...

It would be alot easier if just had one router that had at least 3 ports, one connected to your LAN one connected to the Office LAN and one to your partner's company.. so that you don't have to configure every computer on your LAN with routing stuff...
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
umm.. I you can do it. It kinda differs for each Distro, which one are you using?

The generic manual way is to do it by hand:


route add -net *.*.*.* netmask 255.*.*.* 192.1.1.100
^ ^
l l ^ and the gateway..
l l
the network you are going too.. l
l
it's netmask

if you don't know the network number and the netmask number for the gateway ask the network people for it... and then you repeat the command for the other gateway

otherwise you can specify this perminately in the /etc/sysconfig/static-routing file in RedHat.. others are a bit different...

in redhat its a bit like this

#interface type destination gw ip-address
eth0 net *.*.*.* gw 192.1.1.100
eth0 net *.*.*.* gw 192.1....

as far as the actual ip address are I don't know your network, so You'll have to ask them.. umm.. and check out your distro's documentation for the specific details on the correct syntax and stuff. If you are lucky you'll have a configuration program like linuxconf that can help you out...
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
cool if you only got one router to worry about then all you should have to do is set the router's port that is connected to your lan as the defualt gw and the router should be able to take care of it all, The proccess should be invisible to any computers on you lan.
 

kmthien

Senior member
Oct 8, 2002
363
0
0
Hi,

I have entered the following command:

route add -net 61.2.3.190 netmask 255.255.255.0 gw 192.1.1.100

but failed. It returned some instructions on how to use route command.

61.2.3.190 is the ftp server ipadd of my partner company and 192.1.1.100 is the gateway server. My server ipadd is 192.1.1.50, where it links to the router via a switch. 192.1.1.100 is connected to the router directly.

You means my server 192.1.1.50 can't have 2 default gateway ?

Thanks !

 

Haden

Senior member
Nov 21, 2001
578
0
0
It can, but it would load balance then. You need this supported in kernel thought:
ip route flush all
ip route add 192.168.0.0/16 dev eth0 proto kernel scope link src $IP
ip route add default nexthop via $G1 dev $DEV1 nexthop via $G2 dev $DEV2
where G1/G2 are gateways and DEV1/DEV2 are devices, in your case DEV1=DEV2 (IP your ip)
OR
you might try using them to access different IPs, dunno what you want to accomplish with to gateways...
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |