Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

#/etc/conf.d/net
config_eth0( "dhcp" "192.168.3.42/24" )

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:192.168.3.100  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::217:9aff:feb6:67cc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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:192.168.3.42  Bcast:192.168.3.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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
1  
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

3 Answers 3

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

Sean

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=( "192.168.3.42/24" )
routes_eth0=( "default via 192.168.3.1" )
dns_servers_eth0=( "192.168.3.1" )

192.168.3.1 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

 
discard

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.