# Assign IPv6 address range to interface



## ziyanm (Oct 21, 2012)

Hello all,

I'd like to assign about a dozen IPv6 aliases to an interface, so I can allocate them to jails. I can add a v4 address range by doing this in /etc/rc.conf

```
ipv4_addrs_fxp0="192.168.0.1/24 192.168.1.1-5/28" # example IPv4 address entry.
```

I found a similar directive for v6 called `% ipv6_prefix_<interface>`, which uses EUI64 for the lower bits. I don't think I can use this since I only have a /64 prefix (correct me if I'm wrong.) Is there a standard way to simply specify a v6 address range similar to the  `% ipv4_addrs` directive?


----------



## gkontos (Oct 21, 2012)

The way to assign them in an interface is:


```
####IPv6#### 
ifconfig_em0_ipv6="inet6 [FILE]<ipv6 address>[/FILE] prefixlen 64"
ipv6_defaultrouter="[FILE]<ipv6 gateway>[/FILE]"
```

But if you need to assign them to a jail you don't have to add an alias for them. Example:


```
jail_private_web1_rootdir="/usr/local/jails/private_web1"
jail_private_web1_hostname="my.jail.net"
jail_private_web1_interface="em0"
jail_private_web1_ip="10.49.0.104,fdf1:e5bf:1964:c0d9::49d"
jail_private_web1_devfs_enable="YES"
```

The example above uses non routable IP addresses but you can change it with routable.


----------



## ziyanm (Oct 23, 2012)

Hello gkontos,

Thanks for the tip, but in my case the private IPv4 address and the IPv6 global address are on two different interfaces. So I don't think I can set IPs on multiple interfaces at jail startup. Do you know of a  jail_ setting in rc.conf that lets me do this?
__
Ziyan.


----------



## ziyanm (Oct 23, 2012)

A a careful reading of the rc.conf man page shows that this is indeed possible. Here's my example:


```
jail_debian_ip="lo1|127.40.18.12/32, igb0|10.40.18.12/32, igb3|2401:dd00:30::120c"
```
Note the pipe symbol that separates the interface name and IP. Kudos to gkontos!


----------



## gkontos (Oct 23, 2012)

Assuming that em0 is your private interface and em1 your public:


```
jail_private_web1_rootdir="/usr/local/jails/private_web1"
jail_private_web1_hostname="my.jail.net"
jail_private_web1_interface="em0"
jail_private_web1_ip="10.49.0.104,fdf1:e5bf:1964:c0d9::49d"
jail_private_web1_ip_multi0="em1|2a02:xxx:xxx:deaf::101:0:2"
jail_private_web1_devfs_enable="YES"
```

This will assign both interfaces to the jail with their corresponding IP addresses.


----------

