LinuxQuestions.org
Help answer threads with 0 replies.
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 01-29-2015, 03:42 AM   #1
kssuhesh
LQ Newbie
 
Registered: Aug 2007
Location: Kochi
Distribution: Mandriva
Posts: 24

Rep: Reputation: 15
Unhappy Multiple Gateway for a linux server


Hello,

Is it possible to set multiple gateway to one linux system, so that I can use one for communicate with multiple private networks (172.16.0.0/24, 172.16.1.0/24) and one for internet ?
 
Old 01-29-2015, 07:39 PM   #2
QYInst
LQ Newbie
 
Registered: Jan 2015
Posts: 17

Rep: Reputation: Disabled
Quote:
Originally Posted by kssuhesh View Post
Hello,
Is it possible to set multiple gateway to one linux system, so that I can use one for communicate with multiple private networks (172.16.0.0/24, 172.16.1.0/24) and one for internet ?
Yes, it is possible. This is what route is for.
You can have not only multiple gateways, but also multiple devices.

Let us say, you want to access the private networks through gateway X.X.X.X, device ethA, and internet through gateway Y.Y.Y.Y, device ethB.
You may want to delete the default route rule first. By executing
Code:
$ route -n
You may find a line like
Code:
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0               Z.Z.Z.Z             0.0.0.0              UG     0            0        0      ethC
You can delete it with
Code:
# route del -net 0.0.0.0 netmask 0.0.0.0 dev ethC
Then you just need to add the following routes
Code:
# route add -net 172.16.0.0 netmask 255.255.255.0 gw X.X.X.X dev ethA
# route add -net 172.16.1.0 netmask 255.255.255.0 gw X.X.X.X dev ethA
# route add -net 0.0.0.0 netmask 0.0.0.0 gw Y.Y.Y.Y dev ethB
Remember to replace X/Y/Z and A/B/C according to your real configuration.
 
1 members found this post helpful.
  


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
Configuring server on multiple gateway hellbound1988 Linux - Server 1 01-14-2012 03:47 AM
Destination Host Unreachable On Multiple eth and Multiple Gateway sangprabv Linux - Networking 7 05-28-2010 10:51 AM
GATEWAY SERVER IN Linux vraju040 Linux - Software 7 05-28-2009 01:40 AM
Linux gateway server jayakrishnan Linux - Networking 2 01-23-2009 04:19 AM
Multiple gateway + Multiple DHCPD abakali Linux - Networking 8 12-14-2005 09:09 AM

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

All times are GMT -5. The time now is 08:15 PM.

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