Solved IPV6 aliases in rc.conf

marceloneil

New Member


Messages: 4

I am currently running FreeBSD 12.0-RELEASE-p2, and I can't figure out how to create both IPV4 and IPV6 aliases for a loopback (lo1) interface using rc.conf(5) on boot. Here is a snippet of my /etc/rc.conf:
Code:
cloned_interfaces="lo1"
ifconfig_lo1="inet 10.0.0.0 netmask 255.255.255.0"
ifconfig_lo1_ipv6="inet6 fdxx:xxxx:xxxx::/48"
ifconfig_lo1_alias0="inet 10.0.0.1 netmask 255.255.255.255"
ifconfig_lo1_alias1="inet 10.0.0.2 netmask 255.255.255.255"
ifconfig_lo1_alias2="inet6 fdxx:xxxx:xxxx::1 prefixlen 64"
ifconfig_lo1_alias3="inet6 fdxx:xxxx:xxxx::2 prefixlen 64"
Unfortunately the last two lines don't seem to function properly (no ipv6 aliases are added). Although I can find references of creating ipv6 aliases within the rc.conf(5) manpage under the ifconfig_<interface>_ipv6 section, there are no examples of how to create them alongside with ipv4 aliases.
I would like to run the equivalent of the following on boot, using rc.conf():
Code:
ifconfig lo1 inet 10.0.0.1 netmask 255.255.255.255 alias
ifconfig lo1 inet 10.0.0.2 netmask 255.255.255.255 alias
ifconfig lo1 inet6 fdxx:xxxx:xxxx::1/64 alias
ifconfig lo1 inet6 fdxx:xxxx:xxxx::2/64 alias
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,264
Messages: 29,700

Unfortunately the last two lines don't seem to function properly (no ipv6 aliases are added)
Have a look in /var/log/messages and/or turn on verbose booting. The ifconfig_<int>_aliasN notation should be used for IPv6 aliases too. So at first glance your rc.conf looks to be correct. But there might be other reasons why it's not applying the IPv6 aliases.
 
OP
OP
M

marceloneil

New Member


Messages: 4

Have a look in /var/log/messages and/or turn on verbose booting. The ifconfig_<int>_aliasN notation should be used for IPv6 aliases too. So at first glance your rc.conf looks to be correct. But there might be other reasons why it's not applying the IPv6 aliases.
I enabled verbose mode and rebooted, thanks for the suggestion! However, it doesn't seem to display anything related to aliases (I added boot_verbose="YES" to my loader.conf). Here is the output in /var/log/messages related to lo1:
Code:
Feb  1 10:27:38 coruscant kernel: lo1: bpf attached
Feb  1 10:27:38 coruscant kernel: lo1: link state changed to UP
Here is the output of service netif restart if it at all helpful (the ipv6 aliases were added manually before the restart using ifconfig):
Code:
Stopping Network: lo0 em0 em1 lo1 pflog0.
--- other interfaces excluded ---
lo1: flags=8048<LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 fe80::1%lo1 prefixlen 64 scopeid 0x4
    inet6 fdxx:xxxx:xxxx:: prefixlen 48
    inet6 fdxx:xxxx:xxxx::1 prefixlen 64
    inet6 fdxx:xxxx:xxxx::2 prefixlen 64
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
Destroyed clone interfaces: lo1.
Created clone interfaces: lo1.
sendmsg on em0: No buffer space available
Starting Network: lo0 em0 em1 lo1.
--- other interfaces excluded ---
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo1 prefixlen 64 scopeid 0x4
    inet6 fdxx:xxxx:xxxx:: prefixlen 48
    inet 10.0.0.0 netmask 0xffffff00
    inet 10.0.0.1 netmask 0xffffffff
    inet 10.0.0.2 netmask 0xffffffff
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,264
Messages: 29,700

I'm assuming these are for jails? You don't need to pre-define them. If you set up the jail configuration correctly its IP addresses are automatically added/removed when the jail is started/stopped.

That said, it should work regardless. Have you tried setting these in rc.conf?
Code:
#rc_debug="NO"          # Set to YES to enable debugging output from rc.d
rc_info="NO"            # Enables display of informational messages at boot.
Hopefully that actually logs something or at least provide clues why it's not working.
 
OP
OP
M

marceloneil

New Member


Messages: 4

I'm assuming these are for jails? You don't need to pre-define them. If you set up the jail configuration correctly its IP addresses are automatically added/removed when the jail is started/stopped.
I am! I tried commenting out the alias config in /etc/rc.conf and rebooting, although no addressed were added (not even the ipv4 ones). So I'm pretty sure my jail.conf is misconfigured. Although this isn't directly related to the original question, here is what my /etc/jail.conf currently looks like:
Code:
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
mount.devfs;
host.hostname = "$name.domain.local";
path = "/jails/$name";
ip4.addr = 10.0.0.$ip;
ip6.addr = fdxx:xxxx:xxxx::$ip;

jail1 {
  $ip = 1;
}

jail2 {
  $ip = 2;
}
That said, it should work regardless. Have you tried setting these in rc.conf?
Code:
#rc_debug="NO"          # Set to YES to enable debugging output from rc.d
rc_info="NO"            # Enables display of informational messages at boot.
Hopefully that actually logs something or at least provide clues why it's not working.
I forgot about those! I added this to my rc.conf:
Code:
rc_debug="YES"
rc_info="YES"
Although it didn't report anything related to lo1 or ifconfig in my logs.

Additionally, (sorry I forgot to mention this), I have this setup in my rc.conf from my server provider:
Code:
# Network configuration (IPv4)
ifconfig_em0="inet 192.99.xxx.xxx netmask 255.255.255.0 broadcast 192.99.xxx.255"
defaultrouter="192.99.xxx.254"

# Network configuration (IPv6)
ifconfig_em0_ipv6="inet6 2607:5300:xxxx:xxxx::1 prefixlen 128 accept_rtadv no_radr"
ipv6_network_interfaces="em0"
ipv6_default_interface="em0"
ipv6_defaultrouter="2607:5300:0060:37ff:ff:ff:ff:ff"
ipv6_route_ovhgw="2607:5300:0060:37ff:ff:ff:ff:ff -prefixlen 128 -interface em0"
ipv6_static_routes="ovhgw"
 

chrbr

Aspiring Daemon

Reaction score: 240
Messages: 669

Dear marceloneil,
there is something about scopeid or so to be added. I have tried ipv6 in jails with the config as below.
/etc/rc.conf
Code:
...
ifconfig_lo1_ipv6="inet6 2001:db8:1::1 prefixlen 64"
ipv6_gateway_enable="yes"
...
and /etc/jail.conf
Code:
 box {
          path = "/usr/jails/box";
          host.hostname = "box";
          ip4.addr = "10.0.0.2";
          ip6.addr = "2001:db8:1::2 prefixlen 64";
...
}
If I remember correctly the 2001:db8 something should be some address not to be routed to outside.
In the output of ifconfig -a you will see the scopeid. In my case this should have been the "1" following "db8".

Please search for ipv6 and scopeid for more accurate information.
I hope it helps!
 
OP
OP
M

marceloneil

New Member


Messages: 4

Thanks for the hints SirDice and chrbr!

Ultimately I removed the alias stuff from my rc.conf and modified my jail.conf to include the interface name, which seemed to fix my problem and creates the aliases on jail start.
Code:
ip4.addr = "lo1|10.0.0.$ip";
ip6.addr = "lo1|fdxx:xxxx:xxxx::$ip prefixlen 128";

Although my fix isn't exactly the answer to my original question, this issue is resolved for my purposes.
 

rpowell47

Member

Reaction score: 2
Messages: 30

After adding ipv6_gateway_enable="YES" to rc.conf, the (sendmsg em0: no buffer space available) message is not showing during booting.
 
Top