Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server that I have setup to use dhcp for the main connection information and have an alias set up that my router forwards ports to.

Everytime (I think this is what is happening) dhcp renews the lease. I lose the alias ip.

This is on a Gentoo Linux box

config_eth0( "dhcp" "" )

When I run

/etc/init.d/net.eth0 restart

I get both the dhcp assigned ip and the alias.

eth0      Link encap:Ethernet  HWaddr 00:17:9a:b6:67:cc  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::217:9aff:feb6:67cc/64 Scope:Link
          RX packets:2974019 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2294036 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3110313558 (2.8 GiB)  TX bytes:266296521 (253.9 MiB)
          Interrupt:19 Base address:0x4000 

eth0:1    Link encap:Ethernet  HWaddr 00:17:9a:b6:67:cc  
          inet addr:  Bcast:  Mask:
          Interrupt:19 Base address:0x4000

after a day, I will only have eth0.

What do I have to do so that the alias stays when the dhcp gets renewed?

share|improve this question
Is there some reason why you can't simply setup a static address? – Zoredache Sep 7 '09 at 5:17
I could do that, but I need to be able to get the dns servers dynamically. How would I do that? – Tanj Sep 7 '09 at 13:27

dhclient, if that is what you are using, can accept the argument "-sf" which specifies a script file to run for networking changes. The default is "/sbin/dhclient-script", which you could either wrap that script, or it may provide hooks that you can add the alias with "/etc/dhcp/dhclient-${interface}-up-hooks" or "/etc/dhcp/dhclient-up-hooks" or in scripts in "/etc/dhcp/dhclient.d".


share|improve this answer
up vote 1 down vote accepted

OK, so I decided to set it up as static. I needed a way to get the dns information, which was my reason for using dhcp.

I now have it setup like this.

config_eth0=( "" )
routes_eth0=( "default via" )
dns_servers_eth0=( "" ) is my router.

I was always used to having resolv.conf having the dns servers themselves. I guess I never thought that I could use my router for that.

If there is a better way to do this I would be glad to hear it.

share|improve this answer

If you are using dhclient check the alias declaration inside dhclient.conf. Maybe it will work with eth0:1 as an interface name...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.