大网数据广告活动
服务器运维问答

Add ipv6 to Read Hat 9 loopback interface

· 52CE 我爱测

In a fresh created rhel9 VM the loopback interface doesn't include an IPv6 address but /etc/hosts includes ::1 entry for localhost [vagrant@el9-test-fd5843e6 ~]$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UN…

问题原文

原帖链接 · José · CC BY-SA 4.0

In a fresh created rhel9 VM the loopback interface doesn't include an IPv6 address but /etc/hosts includes ::1 entry for localhost

[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

How can I configure the IPv6 address for the loopback interface? for reference I testing this with the following vagrant box https://app.vagrantup.com/generic/boxes/rhel9

已采纳解答

原帖链接 · larsks · CC BY-SA 4.0

This has nothing to do with RHEL 9. The Vagrant image that you're using explicitly disabled IPv6; take a look at /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

Remove or comment out that line and reboot (or just run sysctl -w net.ipv6.conf.all.disable_ipv6=0) and you should be all set. Just changing the sysctl results in:

[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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-09-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。