Networking

將 ipv6 添加到 Read Hat 9 環回介面

  • September 15, 2022

在新創建的 rhel9 VM 中,環回介面不包含 IPv6 地址,但/etc/hosts包含::1localhost 條目

[vagrant@el9-test-fd5843e6 ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
   inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
   link/ether 08:00:27:02:41:69 brd ff:ff:ff:ff:ff:ff
   altname enp0s3
   inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute eth0
      valid_lft 85325sec preferred_lft 85325sec
   inet6 fe80::a00:27ff:fe02:4169/64 scope link noprefixroute
      valid_lft forever preferred_lft forever
[vagrant@el9-test-fd5843e6 ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1 rhel9.localdomain

如何為環回介面配置 IPv6 地址?作為參考,我使用以下 vagrant box https://app.vagrantup.com/generic/boxes/rhel9對此進行了測試

這與 RHEL 9 無關。您使用的 Vagrant 映像明確禁用了 IPv6;看看/etc/sysctl.conf

[root@node1 sysctl.d]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).


net.ipv6.conf.all.disable_ipv6 = 1

刪除或註釋掉該行並重新啟動(或只是執行sysctl -w net.ipv6.conf.all.disable_ipv6=0),您應該一切就緒。只需將sysctl結果更改為:

[root@node1 sysctl.d]# ip -6 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 state UNKNOWN qlen 1000
   inet6 ::1/128 scope host
      valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
   inet6 fe80::5054:ff:fe62:ca84/64 scope link
      valid_lft forever preferred_lft forever

引用自:https://serverfault.com/questions/1110754