LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-10-2005, 07:09 PM   #1
spadesmaster
LQ Newbie
 
Registered: Dec 2001
Posts: 8

Rep: Reputation: 0
How to get dhcpd.conf to support multiple ISP routers?


I have two ISPs on different routers for our home/small office (192.168.1.1 and 192.168.1.2) and I have been trying to figure out how to get the system to automatically failover if one of the ISPs goes down.

I took the step of setting up dhcpd on our in-house server and I can now do this with a simple 2-line change in my dhcpd.conf and then restart the dhcpd process, but I am looking for an automatic way to do this. Specifically, there are two issues I believe:

1) I need a way to have DHCPD automatically switch preferred router/DNS if one of the gateways become unreachable

2) I would also like a way to have the main server network configuration also switchover its gateway and DNS entries using the same DHCP mapping as #1

Before I write some ugly perl script that runs every minute to ping the gateway, edit the dhcpd.conf file, and restart the process and network configuration, if necessary, can someone tell me if there is a better way to do this? This sure seems to me like something Linux DHCPD should be able to do for me...

I am using RHE 3.0 and my dhcpd.conf file currently looks like this:

Code:
default-lease-time 86400;
max-lease-time 86400;
authoritative;
ddns-update-style none;

# most normal devices on our network use the cable routing by default
subnet 192.168.0.0 netmask 255.255.0.0 {
    range 192.168.1.50 192.168.1.99;

#   default DHCP to cable normally
#   option routers 192.168.1.1;
#   option domain-name-servers 192.168.1.5, 68.87.66.196;

#   switch DHCP to wireless if Comcast is down
    option routers 192.168.1.2;
    option domain-name-servers 67.72.108.2, 67.72.111.2;
}
Thank you very much for assistance!

Last edited by spadesmaster; 09-10-2005 at 07:10 PM.
 
Old 09-10-2005, 07:23 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Since the gateway will only be set when the lease is initially set up I'd suggest setting it to your linux box and then routing traffic from there to your chosen router. This way your clients only ever point to one gateway address and you can even do load ballancing between them when they are both up.
 
Old 09-10-2005, 09:20 PM   #3
spadesmaster
LQ Newbie
 
Registered: Dec 2001
Posts: 8

Original Poster
Rep: Reputation: 0
So you are saying to make my gateway and DNS server the Linux box and always have the DHCP point to it?

Then change which gateway my Linux box uses for itself for routing?

This sounds good, but is beyond my level of knowledge to setup.

Could you please provide some links on setting up this routing and then how my server would pick/fallback to the other gateway when one ISP was down?

And you mentioned load balancing too which would be wonderful, but that DEFINETELY sounds difficult to do.

For now, I just had our server using one ISP and all the PCs on DHCP using the other by default...

Last edited by spadesmaster; 09-10-2005 at 09:22 PM.
 
Old 09-11-2005, 06:51 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I'll not say it's the easist thing to do in the world but I think it will provide you with the best solution in the long run.

You're right about the way I suggested the setup:
Code:
     [Router 1]        [Router 2]
          \               /
         (eth1)        (eth2)
            [Linux Router]
                (eth0)
                  |
             [LAN Switch]
              /        \
           [PC1]      [PC2]
There is information about how to do this here:
http://lartc.org/howto/lartc.rpdb.multiple-links.html
http://www.linuxquestions.org/questi...icle&artid=490

Once you have the linux box working by itself with split access you will need to set up masquerading for your clients as shown here (you'll have 2 wan nics rather than one):
http://www.linuxquestions.org/questi...ticle&artid=23

You could get away with just using 2 NICs in the linux box if you connected the 2 routers and one of the linux NICs using a switch but having them seperate may be easier to manage.

Once you have this set up you can run a cron job to check which providers are up and modify your routing tables if one goes down or comes back up again.
 
Old 09-22-2005, 08:30 AM   #5
spadesmaster
LQ Newbie
 
Registered: Dec 2001
Posts: 8

Original Poster
Rep: Reputation: 0
Thank you for the information. I will look into getting 2 more NICs and setting this up as, I agree, it sounds like this would be the best long-term solution.

In the short-term, is there a way I can automate dhcpd.conf to switch or should I just write a perl script on cron that switches between two dhcpd.conf files based on which ISP is down?
 
Old 09-22-2005, 01:18 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I can't think of a way to automate it except from like you say, just writing a simple script to copy either dhcpd.conf.isp1 or dhcpd.conf.isp2 to dhcpd.conf
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
dhcpd.conf "option routers" non fixed TroelsSmit Linux - Networking 1 08-11-2005 04:31 AM
dhcpd subnet declaration problems in dhcpd.conf vcrispo Linux - Networking 6 07-15-2005 10:32 AM
Setting up multiple routers toejam Linux - Networking 3 06-09-2004 10:08 AM
dhcp.conf or dhcpd.conf? rogerbennett Linux - Networking 3 09-03-2003 12:25 PM
dhcpd.master or dhcpd.conf rickg Linux - Networking 0 04-11-2002 03:34 PM

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

All times are GMT -5. The time now is 08:02 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