1

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?

womble
  • 95,029
  • 29
  • 173
  • 228
Tanj
  • 163
  • 1
  • 1
  • 8

3 Answers3

1

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

Sean Reifschneider
  • 10,370
  • 3
  • 24
  • 28
1

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.

Tanj
  • 163
  • 1
  • 1
  • 8
0

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

kargig
  • 316
  • 1
  • 2