# Network interface alias used by jail disappears until server restart



## danielthegray (Aug 17, 2021)

I have a network interface alias which I declared in /etc/rc.conf, as follows:

```
ifconfig_alc0="DHCP"
ifconfig_alc0_alias0="inet 192.168.1.17/32"
ifconfig_alc0_alias1="inet 192.168.1.16/32"
ifconfig_alc0_alias2="inet 192.168.1.12/32"
```

The jail is configured to use 192.168.1.17 (and two other jails are on each of the other 2).

At some (unknown) point, the 192.168.1.17 address disappears from the list of interfaces of `ifconfig` of the host, and running `ifconfig` from inside the jail shows an interface with no IP address. The problem persists even after restarting the jail, but restarting the entire physical machine fixes it.

I've looked through /var/log for some message/error which would let me find the source of the issue and fix it, but I can't seem to find anything relevant. Is there somewhere else I should be looking?


----------



## SirDice (Aug 17, 2021)

Set the IP address of the jail in your jail.conf. There is no need to define it on the host beforehand. The alias will be automatically created when the jail starts and removed when the jail stops. That will also make restarting the jail work to get the IP address again.



danielthegray said:


> At some (unknown) point, the 192.168.1.17 address disappears from the list of interfaces of `ifconfig` of the host, and running `ifconfig` from inside the jail shows an interface with no IP address.


I suspect this might be due to the 'main' IP address of the interface being set by DHCP. I would suggest using a static address here. DHCP can take the whole interface down, which would automatically remove all IP addresses on it.


----------



## danielthegray (Aug 17, 2021)

OK, thanks for your input. I'll give this a shot and see. I will try to remove it from the host as an alias beforehand as well and see what happens when it is only defined in jail.conf.

The main [imagined] "counterargument" that I would have is that it only took out one of the addresses, not the other two (which are also set up in the same way and also wired up to jails)... if it were due to DHCP "taking down" the interface I would expect the other two to also be gone. Maybe there is a bug somewhere? But anyway, I will set up a static IP address and see if it remains stable over the next few days.

Thanks for your reply!


----------

