我正在尝试在家庭托管的 Debian 11 服务器(实际上只是一台 PC)上设置静态 ipv4 地址和静态 ipv6 地址。
这是我的 /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eno1
iface eno1 inet static
address 192.168.1.149
netmask 24
gateway 192.168.1.1
iface eno1 inet6 static
address 2a01:xxxx:xxxx:xxxx::1234
netmask 56
gateway fe80::712a:e39b:d35a:3ea4
使用“sudo service netowrking restart”重新启动网络服务后,结果如下(正是我想要的):
sept. 15 00:07:56 omen-debian systemd[1]: Starting Raise network interfaces...
sept. 15 00:08:07 omen-debian ifup[785]: Waiting for DAD... Timed out
sept. 15 00:08:07 omen-debian ifup[637]: ifup: failed to bring up eno1
sept. 15 00:08:07 omen-debian systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
sept. 15 00:08:07 omen-debian systemd[1]: networking.service: Failed with result 'exit-code'.
sept. 15 00:08:07 omen-debian systemd[1]: Failed to start Raise network interfaces.
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether c8:d3:ff:e6:b5:59 brd ff:ff:ff:ff:ff:ff
altname enp5s0
inet 192.168.1.149/24 brd 192.168.1.255 scope global eno1
valid_lft forever preferred_lft forever
inet6 2a01:xxxx:xxxx:xxxx::1234/56 scope global
valid_lft forever preferred_lft forever
inet6 fe80::cad3:ffff:fee6:b559/64 scope link
valid_lft forever preferred_lft forever
如您所见,我的网络服务出现错误。我做错了什么?
答案1
这是@asktyagi 的答案,但我在这里添加了以便其他人清楚
在 Debian 11 上,启动后,systemctl status networking.service
将显示无法将 ipv6 地址添加到具有 ipv4 地址的接口。
即使设置/etc/network/interface
为该接口也没有 ipv6 地址
Jan 30 14:07:48 debian11 systemd[1]: Starting Raise network interfaces...
Jan 30 14:07:48 debian11 ifup[543]: RTNETLINK answers: Permission denied
Jan 30 14:07:48 debian11 ifup[478]: ifup: failed to bring up ens192
所以错误是RTNETLINK 回答:权限被拒绝
这些都不起作用
ip -6 addr add IPv6/64 dev ens192 metric 1
并表明没有权限
然后
route -A inet6 add IPv6/64 dev ens192
还展示了没有权限
更改/etc/sysctl.conf
这些选项并没有解决关联
net.ipv6.conf.all.autoconf=0
net.ipv6.conf.all.accept_ra=0
net.ipv6.conf.default.autoconf=0
net.ipv6.conf.default.accept_ra=0
# and
net.ipv6.conf.all.disable_ipv6=1
或者重新排序配置也无济于事关联
工作
net.ipv6.conf.<interface name>.accept_dad = 0
然后重启。
重启后,网络不再出现错误,并且 ipv6 已添加到接口。