Solved

Fallback on static network configuration if dhcp fails

Posted on 2006-07-12
11
1,195 Views
Last Modified: 2010-03-18
I run Debian testing (etch) on my machine.

I have set up another machine that acts as dhcpd server.

Now I want my first machine to get its ip-address and so on from the dhcpd server. But if that server is down I want it to fallback to a static configuration. I use the /etc/network/interface file.

I cannot find any documentation on how to do that. But it must be possible, or?

0
Comment
Question by:Gieron
  • 6
  • 3
  • 2
11 Comments
 
LVL 39

Expert Comment

by:noci
Comment Utility
Well, I havn't seen any distro that can configure this.....,

at first what do you expect...:
First about the static config how different would it be from the dhcp one....
It can't use the address from the ip pool served by dhcp to prevent conflicts... You will have to setup routing
correctly anyway. So why not always use a static setup.?

You could try the following:
Build a script that will start the interface.., first using dhcp if after say 60 seconds the ipaddress is
still unknown then kill the dhcp client and reconfig using the static setup....
And now a big question...
  Will you need to check if the dhcp server is back again?
  Then remove the ip info from the interface and restart the script....
This will of course disrupt any connection that runs when the interface goes down.
 
0
 
LVL 24

Accepted Solution

by:
slyong earned 250 total points
Comment Utility
try to "man 5 dhclient.conf" or look at the online manual pages (http://linuxreviews.org/man/dhclient.conf/)

look under "LEASE DECLARATIONS"

fixed-address ip-address;
The fixed-address statement is used to set the ip address of a particular lease. This is required for all lease statements. The IP address must be specified as a dotted quad (e.g., 12.34.56.78).
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
Hm obviously didn't know this one...,

Better look un Alias declaration and look at the example at the bottom...
it's what you're looking for.
0
 
LVL 24

Expert Comment

by:slyong
Comment Utility
Hi noci,

Not on the Alias Declaration, as my previous post stated look under "Lease Declaration" there is a parameter call "fixed-address".  You need a pair of (new) glasses :D
0
 
LVL 39

Assisted Solution

by:noci
noci earned 250 total points
Comment Utility
Not exactly a new pair of glasses....
Please look at the sample supplied:
This is what he needs (mutatis mutandis, yes also fixed-address, but as an alias in case the dhcp negotiation fails....)

timeout 60;
retry 60;
reboot 10;
select-timeout 5;
initial-interval 2;
reject 192.33.137.209;

interface "ep0" {
    send host-name "andare.fugue.com";
    send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
    send dhcp-lease-time 3600;
    supersede domain-name "fugue.com rc.vix.com home.vix.com";
    prepend domain-name-servers 127.0.0.1;
    request subnet-mask, broadcast-address, time-offset, routers,
            domain-name, domain-name-servers, host-name;
    require subnet-mask, domain-name-servers;
    script "/sbin/dhclient-script";
    media "media 10baseT/UTP", "media 10base2/BNC";
}

alias {
  interface "ep0";
  fixed-address 192.5.5.213;
  option subnet-mask 255.255.255.255;
}
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 24

Expert Comment

by:slyong
Comment Utility
my bad, but take note that about what is said in alias declaration:

>       The  alias  declaration  resembles  a  lease  declaration,  except that
>       options other than the subnet-mask option are ignored by  the  standard
>       client  configuration  script, and expiry times are ignored.

As far as possible, try to use lease declaration because it will still falls back to DHCP lease when the lease time is up.
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
Normally a new lease is started after half the time of the old lease has expired, so there should be enough time to renegotiate.
If that expires, then what is whisdom....

with dhcpcd you loose everything.
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
Besides this all...

A dhcp server should be regarded is mission critical like ldap, dns etc. (if used)
It should run on hardware that will be available, virtually always.

If it fails basicly your network fails as they are part of your infra structure
what assumptions can you make about your network as a whole when
parts of it fail...?
0
 
LVL 2

Author Comment

by:Gieron
Comment Utility
Some background information:

>First about the static config how different would it be from the dhcp one....

Basically the same. It would just lack gateway and dns information.

>It can't use the address from the ip pool served by dhcp to prevent conflicts... You will have to setup routing

The dhcp server gives it a static ip address. I wish to give it the same address in case the dhcp server is down.

>correctly anyway. So why not always use a static setup.?

Because I want to be difficult :)

>If it fails basicly your network fails as they are part of your infra structure
>what assumptions can you make about your network as a whole when
>parts of it fail...?

That would be true for any production network. But this is just my own home network.

The server that serves dhcp request is also the gateway and dns server. I don't want the rest of the network (especially my file server and workstation) to stop talking to each other just because that server is down.

Besides, shouldn't this be a fairly common problem for people that use linux on their laptops. They may use dhcp at work but need static ip at home. Windows can handle this with ease.
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
>It can't use the address from the ip pool served by dhcp to prevent conflicts... You will have to setup routing

The dhcp server gives it a static ip address. I wish to give it the same address in case the dhcp server is down.

That should be OK.
--
Besides, shouldn't this be a fairly common problem for people that use linux on their laptops. They may use dhcp at work but need static ip at home. Windows can handle this with ease.

Well windows falls back on UPNP and that opens quite another can of worms..
--

Besides many people use something like a cable modem/ adsl link... many of those are DHCP enabled. ==>
if it's on, there is a network..

Normaly in a production network mission critical servers almost never use DHCP..




0
 
LVL 2

Author Comment

by:Gieron
Comment Utility
I have tried to use both the alias and the lease ides proposed here.

The alias seems to work if the dhcp server is unavailable at boot. But it does not work if the dhcp server disappears while running and the lease expires.

The lease method sounds more promising. But I could not get it to work. I put the following in my /etc/dhclient.conf file but the dhcp client just ignored it:

lease {
  interface "eht0";
  fixed-address 192.168.1.4;
  option subnet-mask 255.255.255.0;
}

I think I will stop being difficult and just use a static setup. That will probably work best anyway.

I will split the points evenly between slyong's lease idea and noci's alias idea. Hopefully someone who looks at the PAQ can get some help from that.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now