我当前正在运行 FreeBSD 12.0-RELEASE-p2
,但我不知道如何在启动时为环回 ( lo1
) 接口创建 IPV4 和 IPV6 别名rc.conf
。这是我的一个片段rc.conf
:
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_alias0_ipv6="inet6 fdxx:xxxx:xxxx::1/64"
ifconfig_lo1_alias1_ipv6="inet6 fdxx:xxxx:xxxx::2/64"
不幸的是,最后两行似乎无法正常运行(没有添加 ipv6 别名)。尽管我可以在联机帮助页中找到创建 ipv6 别名的参考,但没有说明如何与 ipv4 别名一起创建它们。
我想在启动时运行相当于以下内容的命令rc.conf
:
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
编辑:我尝试rc.conf
像这样修改我的:
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"
然后重新启动netif:
# service netif restart
Stopping Network: lo0 em0 em1 pflog0 lo1.
-- OTHER INTERFACES EXCLUDED --
lo1: flags=8048<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
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.
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>
同样,它似乎只是忽略了 ipv6 地址,但以下工作正常:
ifconfig lo1 inet6 fd7e:d071:2503::1/64 alias
ifconfig lo1 inet6 fd7e:d071:2503::2/64 alias
答案1
ifconfig_lo1_alias2
, 不是ifconfig_lo1_alias0_ipv6
。等等。
手册中特别指出了这一点rc.conf
,并举例说明了这一点。