# dhclient trashing alias IP address upon reconnect



## Bill Evans at Mariposa (Nov 27, 2016)

When a host boots, I don't want DHCP to come up right away; I want that to wait until an arbitrary point later. But what I do want at boot time is a hard IP address (for example, 10.0.0.3) to be automatically associated with the interface. I use `ifconfig(8)` for that in an rc file, and it works.

Later, at an arbitrary point, I use `dhclient(8)` with only one parameter: the interface name. This adds an IP address to that interface, and the old hard IP address remains. Fine so far.

The problem arises when the network cable is disconnected and then reconnected. At that point, the DHCP IP address remains, but the previously defined hard IP address (in this example, 10.0.0.3) disappears. Sad!

For now my workaround is to launch a Perl script at boot time which checks once a minute, detects the problem, and uses, say, `ifconfig em0 10.0.0.3 netmask 255.255.255.0 alias` to patch things up. Is there a way I can change the behavior of `dhclient(8)` so I don't need this workaround?


----------



## kpa (Nov 27, 2016)

You can use a dhclient.conf(5) entry like this to guarantee that the alias is re-applied every time the interface gets a new address from DHCP (or the old lease is re-applied):


```
alias {
             interface "em0";
             fixed-address 10.0.0.3;
             option subnet-mask 255.255.255.0;
           }
```


----------

