second alias

hi, im going to add ip alias in freebsd, but unsure howto add second ip, ifconfig re0 ip netmask alias, but with second ip , is it ifcofnig re0 ip netmask alias2 ?

Hi, I'm going to add an IP alias in FreeBSD, but am unsure how to add a second IP address.
[cmd=]ifconfig re0 ip netmask alias[/cmd]
But with the second IP address, is it
[cmd=]ifconfig re0 ip netmask alias2[/cmd]
?
 
You can use ifconfig as
Code:
$ ifconfig re0 192.168.0.1 netmask 255.255.0.0 alias
$ ifconfig re0 192.168.0.2 netmask 255.255.0.0 alias
to add as many aliases as you want, but you'll need to add it to your /etc/rc.conf to make the aliases persist across a reboot as gkontos demonstrated.
 
idownes said:
You can use ifconfig as
Code:
$ ifconfig re0 192.168.0.1 netmask 255.255.0.0
$ ifconfig re0 192.168.0.2 netmask 255.255.0.0
to add as many aliases as you want, but you'll need to add it to your /etc/rc.conf to make the aliases persist across a reboot as gkontos demonstrated.

@idownes He could shoot his connection down with your commands if applying to egress interface. You probably forgot the alias word in ifconfig syntax:

Code:
ifconfig re0 alias <IP_ALIAS-1> netmask <MASK>
ifconfig re0 alias <IP_ALIAS-N> netmask <MASK>

It took me some time to remember how to remove the IP though. I did cut my connection several times over these years. So just for the safety sake:

Code:
ifconfig re0 -alias <IP_ALIAS_TO_REMOVE>

..and use the @gkontos way to make it permanent. I think on FreeBSD 9 it automatically activates those IPs (though this is not always wanted situation).
 
Put this in rc.conf(5)

Code:
ipv4_addrs_re0="a.b.c.d/nn"

Where a.b.c.d is the address and nn is the subnet mask in CIDR notation (usually 24).

If you want more aliases you just add them to the list, for example:

Code:
ipv4_addrs_re0="10.0.0.1/16 192.168.1.101/24 172.31.42.42/24"

Note that you use the proper netmasks in the list, the system automatically detects if the netmask 255.255.255.255 (/32 in CIDR) is needed in the actual configuration.
 
Back
Top