# IPv6 aliases on rc.conf?



## minimike (Sep 15, 2011)

Hi there

I've got a /64 IPv6 Subnet registered by RIPE with my name on my own company now. And now I want to have some IPv6 Aliases starting automatically after each reboot. On /etc/rc.conf I've tried 

```
ipv6_ifconfig_bge0_alias0="my_ipv6_address prefixlen 64"
```
without success
What will be the correct way?

cheers
Darko


----------



## ecazamir (Sep 15, 2011)

My full IPv6 config parameters are:

```
ipv6_enable="YES"
ipv6_defaultrouter="2001:ffff:ffff::1"
ipv6_ifconfig_em0="2001:ffff:ffff::2/64"
```

I don't use multiple addresses.
All the possible parameters are documented on the rc.conf(5) manual page.


----------



## minimike (Sep 15, 2011)

So It's impossible to set alias IP's with IPv6 on a Interface?


----------



## ecazamir (Sep 16, 2011)

Not true, it is possible to use multiple adresses on a specific interface. 
Here's my /etc/rc.conf relevant contents:


```
ipv6_enable="YES"
ipv6_ifconfig_em0="fec0:0:0:1::80/64"
ipv6_ifconfig_em0_alias0="fec0:0:0:2::80/64"
ipv6_ifconfig_em0_alias1="fec0:0:0:3::80/64"
```

I used only site-local addresses on my example. The machine automatically gets a link-local address if ipv6 is enabled.
Just make sure that you start numbering aliases from 0.
You can restart (to be more specific: enable new configured addresses) ipv6 network using 
	
	



```
/etc/rc.d/network_ipv6 restart
```


----------



## DutchDaemon (Sep 16, 2011)

This is all literally in rc.conf(5)

*FreeBSD 8.x*

```
ipv6_network_interfaces
                 (str) This is the IPv6 equivalent of network_interfaces.
                 Instead of setting the ifconfig variables as
                 ifconfig_<interface> they should be set as
                 ipv6_ifconfig_<interface>.  Aliases should be set as
                 ipv6_ifconfig_<interface>_alias<n>.
```
*FreeBSD 9.x*

```
ifconfig_<interface>_ipv6
                 (str) IPv6 functionality on an interface should be configured
                 by ifconfig_<interface>_ipv6, instead of setting ifconfig
                 parameters in ifconfig_<interface>.  Aliases should be set by
                 ifconfig_<interface>_alias<n> with ``inet6'' keyword.  For
                 example:

                 ifconfig_ed0_ipv6="inet6 2001:db8:1::1 prefixlen 64"
                 ifconfig_ed0_alias0="inet6 2001:db8:2::1 prefixlen 64"
```


----------



## Terry_Kennedy (Mar 8, 2017)

DutchDaemon said:


> This is all literally in rc.conf(5)


How do you configure both an IP and IPv6 alias on FreeBSD 10.3? I tried:

```
ifconfig_ix0_alias0="inet 10.20.30.250 netmask 0xffffffff inet6 1020:30:1:2::250"
```
and
	
	



```
ifconfig_ix0_alias0="inet 10.20.30.250 netmask 0xffffffff"
ifconfig_ix0_alias0="inet6 1020:30:1:2::250"
```
The first didn't set the IPv6 address, and the second didn't set the IP address (presumably due to having two different _ifconfig_ix0_alias0_ipv6_ lines, and the last one seen taking precedence). Neither one logged anything relevant to the console during boot.

This started out on FreeBSD 8.4 as:

```
ifconfig_ix0_alias0="inet 10.20.30.250 netmask 0xffffffff"
ipv6_ifconfig_ix0_alias0="1020:30:1:2::250"
```
However, that gives me the warning about _ipv6_ifconfig_ix0_alias0_ being deprecated in 10.3.


----------



## ShelLuser (Mar 8, 2017)

Terry_Kennedy said:


> How do you configure both an IP and IPv6 alias on FreeBSD 10.3?


Well, the example which you set up 2 aliases should work. But obviously you can't use alias0 two times, also see rc.conf(5). So I'd wager:


```
ifconfig_ix0_alias0="inet 10.20.30.250 netmask 0xffffffff"
ifconfig_ix0_alias1="inet6 1020:30:1:2::250"
```
This is of course assuming that the IPv4 part is also an alias and not the main IP address which you wanted to use. (edit) Note: you probably need to specify a netmask with the IPv6 part. But that's speculation on my end right now, however based on what I picked up in the manualpage.


----------



## masteroman (Mar 8, 2017)

For IPv4 I have:

```
ifconfig_em0="inet 1.2.3.4 netmask yournetmask"
ifconfig_em0_alias1="inet 1.2.3.5 netmask yournetmask"
```

for IPv6:

```
ifconfig_em0_ipv6="inet6 youripv6 prefixlen 64"
ifconfig_em0_alias1_ipv6="inet6 youripv6 prefixlen 64"
```

basically the same. After changing make sure you restart network with:
`service netif restart && service routing restart`


----------



## Terry_Kennedy (Mar 9, 2017)

ShelLuser said:


> Well, the example which you set up 2 aliases should work. But obviously you can't use alias0 two times, also see rc.conf(5). So I'd wager:
> 
> 
> ```
> ...


Thanks. I used:
	
	



```
ifconfig_ix0_alias0="inet 10.20.30.250 netmask 0xffffffff"
ifconfig_ix0_alias1_ipv6="inet6 1020:30:1:2::250"
```
and so forth for the various aliases.


> (edit) Note: you probably need to specify a netmask with the IPv6 part. But that's speculation on my end right now, however based on what I picked up in the manualpage.


If the alias is on the same subnet as the main interface, it inherits the mask of the main interface.

When I did:

```
(0:1) host:/etc# /etc/rc.d/netif restart
```
I got:
	
	



```
ifconfig: ioctl (SIOCDIFADDR): Can't assign requested address
ifconfig: ioctl (SIOCDIFADDR): Can't assign requested address
```
but that is probably due to the IPv4 addresses already being present as aliases. I'll check to make sure nothing like that is logged the next time I reboot.


----------

