ipv6有効だとちゃんとネット関連で対応してないと遅くなったりするのでとりあえず無効にしたい。
TLTR
/etc/sysctl.confに以下を追加
|
net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1 |
/etc/netplan/(file).yamlに以下を追加
link-local: [ ipv4 ]
バージョン確認
|
$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS" $ |
今現在ipv6が有効になっているかを確認する ip a
|
$ ip a | grep inet6 inet6 ..... inet6 ..... $ |
有効になっているとinet6が表示される。
無効にする
無効にするには/proc/sys以下のカーネル設定を叩けばいいがこれをやるコマンドがsysctl
。この設定ファイル/etc/sysctl.confに以下の三行を追加する。
|
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 |
この設定を反映するには、sysctl -p
|
$ sudo sysctl -p net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 $ $ sudo sysctl -a | grep disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.ens32.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 |
これで永続的に無効になるはずなのになぜか無効にならない。再起動後の値が以下。
|
$ sudo sysctl -a | grep disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.ens32.disable_ipv6 = 0 net.ipv6.conf.lo.disable_ipv6 = 1 $ |
netplanが有効にしてるかもしれないので試してみる。netplanはubuntu serverでipの設定をしているものらしい。
|
$ sudo sysctl -a | grep disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.ens32.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 $ $ sudo netplan apply $ $ sudo sysctl -a | grep disable_ipv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.ens32.disable_ipv6 = 0 net.ipv6.conf.lo.disable_ipv6 = 1 $ |
やはりnetplanが設定を変えてしまうようだ。そこでnetplanの設定ファイル/etc/netplan/以下の.yamlファイルに以下のようにlink-local: [ ipv4 ]
を追加したら再起動しても無効になった。
|
# This is the network config written by 'subiquity' network: ethernets: ens32: addresses: - 192.168.3.97/24 gateway4: 192.168.3.1 link-local: [ ipv4 ] nameservers: addresses: - 192.168.3.1 search: [] version: 2 ~ |