设置

设置

设置

我在 online.net 上的 debian 服务器正在运行双栈 ipv4/ipv6

# /etc/network/interfaces

auto lo
iface lo inet loopback

source /etc/network/interfaces.d/*

/etc/network/interfaces.d/ 中有 2 个文件

# /etc/network/interfaces.d/device-enp0s20-inet

auto enp0s20
iface enp0s20 inet dhcp

# /etc/network/interfaces.d/device-enp0s20-inet6

auto enp0s20
iface enp0s20 inet6 dhcp
  request_prefix 1
  accept_ra 2

我请求我的IPv6 委托前缀使用 dhclient

# /etc/dhcp/dhclient.conf

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


interface "enp0s20" {                                                                                                                                                                                 
  send dhcp6.client-id XX:XX:XX:XX:XX:XX:XX:XX:XX:XX;
}

在 enp0s20 的 inet6 设置中,我想要 accept_ra=2,因为我的内核中有 net.ipv6.conf.all.forwarding=1(我打算设置一个 vpn)。

问题

每次重新启动网络服务都会失败。

$ sudo serving networking restart # first attempt
Job for networking.service failed because a timeout was exceeded.
See "systemctl status networking.service" and "journalctl -xe" for details.
$ sudo service networking restart # second attempt works fine (this cycles)

启动网络服务在启动时也总是失败。

日志

我启用它是为了更好地查看发生了什么

# /etc/default/networking
VERBOSE=yes

以下是重启失败时我从 journalctl 获得的信息:

Apr 03 12:38:37 boxname ifup[4135]: ifup: parsing file /etc/network/interfaces.d/device-enp0s20-inet
Apr 03 12:38:37 boxname ifup[4135]: ifup: parsing file /etc/network/interfaces.d/device-enp0s20-inet6
Apr 03 12:38:37 boxname ifup[4135]: /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
Apr 03 12:38:37 boxname ifup[4135]: ifup: configuring interface enp0s20=enp0s20 (inet)
Apr 03 12:38:37 boxname ifup[4135]: /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
Apr 03 12:38:37 boxname ifup[4135]: /sbin/dhclient -4 -v -pf /run/dhclient.enp0s20.pid -lf /var/lib/dhcp/dhclient.enp0s20.leases -I -df /var/lib/dhcp/dhclient6.enp0s20.leases enp0s20
Apr 03 12:38:37 boxname ifup[4135]: Internet Systems Consortium DHCP Client 4.3.5
Apr 03 12:38:37 boxname ifup[4135]: Copyright 2004-2016 Internet Systems Consortium.
Apr 03 12:38:37 boxname ifup[4135]: All rights reserved.
Apr 03 12:38:37 boxname ifup[4135]: For info, please visit https://www.isc.org/software/dhcp/
Apr 03 12:38:38 boxname ifup[4135]: Listening on LPF/enp0s20/<REDACTED>
Apr 03 12:38:38 boxname ifup[4135]: Sending on   LPF/enp0s20/<REDACTED>
Apr 03 12:38:38 boxname ifup[4135]: Sending on   Socket/fallback
Apr 03 12:38:38 boxname ifup[4135]: DHCPDISCOVER on enp0s20 to 255.255.255.255 port 67 interval 4
Apr 03 12:38:38 boxname ifup[4135]: DHCPREQUEST of 163.172.XX.XX on enp0s20 to 255.255.255.255 port 67
Apr 03 12:38:38 boxname ifup[4135]: DHCPOFFER of 163.172.XX.XX from 163.172.XX.1
Apr 03 12:38:38 boxname ifup[4135]: DHCPACK of 163.172.XX.XX from 163.172.XX.1
Apr 03 12:38:38 boxname ifup[4135]: bound to 163.172.XX.XX -- renewal in 2147483648 seconds.
Apr 03 12:38:38 boxname ifup[4135]: /bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
Apr 03 12:38:38 boxname ifup[4135]: run-parts: executing /etc/network/if-up.d/000resolvconf
Apr 03 12:38:38 boxname ifup[4135]: run-parts: executing /etc/network/if-up.d/openntpd
Apr 03 12:38:38 boxname ifup[4135]: run-parts: executing /etc/network/if-up.d/openssh-server
Apr 03 12:38:38 boxname ifup[4135]: run-parts: executing /etc/network/if-up.d/upstart
Apr 03 12:38:38 boxname ifup[4135]: ifup: configuring interface enp0s20=enp0s20 (inet6)
Apr 03 12:38:38 boxname ifup[4135]: /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
Apr 03 12:38:38 boxname ifup[4135]: /sbin/modprobe -q net-pf-10 > /dev/null 2>&1 || true # ignore failure.
Apr 03 12:38:38 boxname ifup[4135]: /sbin/sysctl -q -e -w net.ipv6.conf.enp0s20.accept_ra=2
Apr 03 12:38:38 boxname ifup[4135]: /bin/ip link set dev enp0s20  up
Apr 03 12:38:38 boxname ifup[4135]: /lib/ifupdown/wait-for-ll6.sh
Apr 03 12:38:39 boxname ifup[4135]: /sbin/dhclient -6 -pf /run/dhclient6.enp0s20.pid -lf /var/lib/dhcp/dhclient6.enp0s20.leases -I -P -N -df /var/lib/dhcp/dhclient.enp0s20.leases enp0s20
Apr 03 12:38:50 boxname ifup[4135]: RTNETLINK answers: Invalid argument

问题

你能帮助我找出问题所在并修复它吗?

答案1

我发现问题了!

经过一番研究,我发现dhcpv6 的工作方式是客户端从端口 546 通信,服务器从端口 547 通信。我添加了以下两个 ip6tables 规则,使我的盒子充当客户端:

-A INPUT -p udp --sport 547 --dport 546 -j ACCEPT
-A OUTPUT -p udp --sport 546 --dport 547 -j ACCEPT

这解决了该问题。

这个问题之所以发生,只是因为我使用了防火墙,并且无意中阻止了 dhcpv6。如果您没有使用防火墙,则不需要这些规则,并且本文无法解决您的问题。

相关内容