FreeBSD/Managing Aliases

From TomJudge.com
Jump to: navigation, search

If you are running jail hosts you no doubt have a large number of aliases on your boxes. And when you need to add and remove aliases it can be a pain if you have to renumber the list.

Here is a method of dynamically numbering the aliases so that that you don't have to remember to do it. (Unless you change alias0).

For non consecutive addresses:

ifconfig_bce0="inet 192.168.0.1/24"
ifconfig_bce0_alias0="inet 192.168.0.2/32"
eval ifconfig_bce0_alias$(( bce0_alias += 1))=\"inet 192.168.0.3/32\"
eval ifconfig_bce0_alias$(( bce0_alias += 1))=\"inet 192.168.0.8/32\"
eval ifconfig_bce0_alias$(( bce0_alias += 1))=\"inet 192.168.0.10/32\"
eval ifconfig_bce0_alias$(( bce0_alias += 1))=\"inet 192.168.0.20/32\"

For consecutive addresses:

ipv4_addrs_bce0="192.168.0.1-5/24"
Personal tools