Add a virtual interface in FreeBSD

IP aliases are easy to add to Linux, and the process is pretty much the same from distribution to distribution.  Well, it’s a little more structured in FreeBSD.  One major thing to keep in mind is what while Linux doesn’t seem to care (usually) if you start at, for example, eth0:1 then have eth0:3 and eth0:5 even without an eth0:0, 0:2, 0:4, etc, FreeBSD must be done in order, starting from alias 0.  Here’s how it’s done:

  • From command line, type ‘ifconfig’ without the quotes to see what the current ethernet interface is.  You should see something like:
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=b<RXCSUM,TXCSUM,VLAN_MTU>
inet6 fe80::230:48ff:fe2c:fa74%em0 prefixlen 64 scopeid 0x1
inet 20X.2XX.240.77 netmask 0xfffffc00 broadcast 20X.2XX.24X.2XX
  • as root, configure the new IP as an alias:
ifconfig em0 20X.2XX.240.78 netmask 255.255.255.255 alias

Leave a Reply