I am trying to add an alias to my network card (I would like to use jails) on my FreeBSD box. It is running version 10.2-RELEASE-p7 (generic amd64 kernel). The machine is running in a Hyper-V virtual machine, but I experience the same thing on my physical box, the only difference is that is is running the x86 (32bit) version of the same 10.2 kernel.
The network interface hn0 has a static IP address: 192.168.0.51/24, my default router is 192.168.0.1. Everything works fine, until I add the alias:
ifconfig hn0 inet 192.168.0.200/32 alias
This creates the alias on hn0 as ifconfig shows:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384 options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6> inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 inet 127.0.0.1 netmask 0xff000000 nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> hn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=31b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,TSO6> ether 00:15:5d:00:0f:00 inet 192.168.0.51 netmask 0xffffff00 broadcast 192.168.0.255 inet 192.168.0.200 netmask 0xffffffff broadcast 192.168.0.200 nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
The problem is that as soon as I have the alias in place, I cannot reach any host outside my subnet (even when using the host's IP address). E.g. a google nameserver:
ping 126.96.36.199 ping 188.8.131.52 (184.108.40.206): 56 data bytes
However, I can ping anything using the alias as the source:
ping -S 192.168.0.200 220.127.116.11 PING 18.104.22.168 (22.214.171.124) from 192.168.0.200: 56 data bytes 64 bytes from 126.96.36.199: icmp_seq=0 ttl=56 time=11.137 ms ...
If the alias is created by jail(8) when starting a jail, the jail using the alias has network access, while the host does not. After removing the alias I have to restart the services netif and routing to regain network access on the primary IP of the host.
When the jail runs, I can ssh into it or I can ping it using the IP alias.
Based on the fact that I cannot ping external nodes using their IP my guess would be that there is something wrong with the routing. Name resolving does not work as my box is unable to reach the DNS servers. Here is my netstat -rn output before adding the alias:
Destination Gateway Flags Netif Expire default 192.168.0.1 UGS hn0 127.0.0.1 link#1 UH lo0 192.168.0.0/24 link#2 U hn0 192.168.0.51 link#2 UHS lo0
and after the alias has been created:
Destination Gateway Flags Netif Expire default 192.168.0.1 UGS hn0 127.0.0.1 link#1 UH lo0 192.168.0.0/24 link#2 U hn0 192.168.0.51 link#2 UHS lo0 192.168.0.200 link#2 UHS lo0 192.168.0.200/32 link#2 U hn0
IPv6 values are omitted as I have disabled IPv6 by adding
I am no expert at network setup, but I have read everything I could find about jails and IP aliases but I haven't found anything helpful. Maybe I am overlooking something trivial, but I have no idea what breaks network access on the host.