Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Fallback on static network configuration if dhcp fails

Posted on 2006-07-12
11
1,327 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 40

Expert Comment

by:noci
ID: 17095515
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
ID: 17095977
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 40

Expert Comment

by:noci
ID: 17096036
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 24

Expert Comment

by:slyong
ID: 17096048
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 40

Assisted Solution

by:noci
noci earned 250 total points
ID: 17096071
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
 
LVL 24

Expert Comment

by:slyong
ID: 17096108
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 40

Expert Comment

by:noci
ID: 17097081
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 40

Expert Comment

by:noci
ID: 17097272
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
ID: 17104424
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 40

Expert Comment

by:noci
ID: 17104562
>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
ID: 17104722
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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

828 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