I have an EC2 instance with 2 jails, it's jail.conf looks like:
The ena0 interface is setup for DHCP (this is the default provided by the image):
I also have some PF rules to forward traffic to the jails and setup NAT:
When this is all working as expected the interface has all expected IPs:
However, sometimes when I go to use one of the jails (often the next day), I can't access it and have found that the ena0 interface only has some of the IPs:
Rebooting the VM or restarting whichever jails are missing their IP assignment resolves the issue and the IP gets re-added and networking works again.
I suspect this is related to using DHCP on ena0 but I if I try to disable DHCP, on reboot the setting in rc.conf is reset back to DHCP (I suspect by cloudinit)
Code:
jail1 {
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";
allow.raw_sockets;
exec.clean;
mount.devfs;
path = "/jail/${name}";
ip4.addr = 10.0.0.11;
interface = ena0;
persist;
}
jail2 {
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";
allow.raw_sockets;
exec.clean;
mount.devfs;
path = "/jail/${name}";
ip4.addr = 10.0.0.12;
interface = ena0;
persist;
}
The ena0 interface is setup for DHCP (this is the default provided by the image):
Code:
ifconfig_ena0=DHCP
I also have some PF rules to forward traffic to the jails and setup NAT:
Code:
nat on ena0 from 10.0.0.0/23 to any -> 10.0.0.10
rdr on ena0 proto tcp from any to any port 80 -> 10.0.0.11 port 8080
rdr on ena0 proto tcp from any to any port 443 -> 10.0.0.11 port 4443
rdr on ena0 proto tcp from any to any port 22 -> 10.0.0.12 port 2223
pass in on ena0 proto tcp from any to any port { 22, 80, 443 } keep state
pass out on ena0 proto { tcp udp icmp } from any to any keep state
When this is all working as expected the interface has all expected IPs:
Code:
#ifconfig ena0
ena0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 9001
options=422<TXCSUM,JUMBO_MTU,LRO>
ether 02:02:91:7d:93:85
inet 10.0.0.11 netmask 0xfffffe00 broadcast 10.0.1.255
inet 10.0.0.10 netmask 0xfffffe00 broadcast 10.0.1.255
inet 10.0.0.12 netmask 0xfffffe00 broadcast 10.0.1.255
media: Ethernet autoselect (Unknown <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
However, sometimes when I go to use one of the jails (often the next day), I can't access it and have found that the ena0 interface only has some of the IPs:
Code:
# yesterday, missing one jail IP
ena0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 9001
options=422<TXCSUM,JUMBO_MTU,LRO>
ether 02:02:91:7d:93:85
inet 10.0.0.11 netmask 0xfffffe00 broadcast 10.0.1.255
inet 10.0.0.10 netmask 0xfffffe00 broadcast 10.0.1.255
media: Ethernet autoselect (Unknown <full-duplex>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
# today, missing both jail IPs
ena0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 9001
options=422<TXCSUM,JUMBO_MTU,LRO>
ether 02:02:91:7d:93:85
inet 10.0.0.10 netmask 0xfffffe00 broadcast 10.0.1.255
media: Ethernet autoselect (Unknown <full-duplex>)net
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Rebooting the VM or restarting whichever jails are missing their IP assignment resolves the issue and the IP gets re-added and networking works again.
I suspect this is related to using DHCP on ena0 but I if I try to disable DHCP, on reboot the setting in rc.conf is reset back to DHCP (I suspect by cloudinit)