VirtualBoxの仮想マシンでIPv6を使う

仮想マシンにCentOS 7を入れる。
しかし、ネットワークにブリッジアダプターを割り当てるが、IPv6で通信できない。
コマンドip addrを実行すると、"dadfailed"というものが表示される。
調べると、IPv6 'dadfailed' Problemを見つける。
"dad"はDuplicate Address Detectionの意味らしい。
その書き込みにあるコマンドを行うと同じ結果を得る。
# sysctl -a | grep accept_dad
net.ipv6.conf.all.accept_dad = 0
net.ipv6.conf.default.accept_dad = 1
net.ipv6.conf.eth0.accept_dad = 1
net.ipv6.conf.lo.accept_dad = -1
実際に
sysctl -w net.ipv6.conf.eth0.accept_dad=0
systemctl restart network
を行うと、IPv6で通信できる。
ところが、仮想マシンを再起動するとこの設定は解除される。
そこでOSを起動するときに実行されるために、このコードを/etc/rc.d/rc.localに追加する。
echo "sysctl -w net.ipv6.conf.eth0.accept_dad=0" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
なお、eth0はアダプタータイプが準仮想化ネットワークのときのデバイス名で、他のアダプタータイプを選ぶとデバイス名は変わるが、IPv6を有効にする方法は同じだ。
2018/10/07 21:05
タグ