# second alias



## evgeni22 (Jul 1, 2012)

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]
?


----------



## gkontos (Jul 1, 2012)

Just add this in /etc/rc.conf


```
ifconfig_re0_alias0="inet xxx.xxx.xxx.xxx  netmask 255.255.255.255"
```


----------



## idownes (Jul 1, 2012)

You can use ifconfig as

```
$ 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.


----------



## _martin (Jul 1, 2012)

idownes said:
			
		

> You can use ifconfig as
> 
> ```
> $ ifconfig re0 192.168.0.1 netmask 255.255.0.0
> ...



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


```
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: 


```
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).


----------



## idownes (Jul 1, 2012)

Sorry, yes don't forget alias!


----------



## kpa (Jul 1, 2012)

Put this in rc.conf(5)


```
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:


```
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.


----------

