LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to get dhcpd.conf to support multiple ISP routers? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-get-dhcpd-conf-to-support-multiple-isp-routers-362192/)

spadesmaster 09-10-2005 07:09 PM

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!

david_ross 09-10-2005 07:23 PM

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.

spadesmaster 09-10-2005 09:20 PM

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...

david_ross 09-11-2005 06:51 AM

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.

spadesmaster 09-22-2005 08:30 AM

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?

david_ross 09-22-2005 01:18 PM

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


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