Por que meus scripts if-up.d estão sendo executados antes que o DHCP (v6) seja concluído?

2

Estou usando o DHCP e tenho IPv4 e IPv6. Desejo executar um script que atualize um serviço IPv6 DDNS quando minha rede estiver configurada.

Eu criei um script em /etc/network/if-up.d/update_dns , mas esse script falha com um erro de resolução de DNS ( curl: (6) Could not resolve host: dynv6.com ). Os logs parecem mostrar que está sendo executado antes do término do DHCP IPv6. Acho que talvez seja porque o IPv4 está pronto e os scripts são acionados.

Existe algum outro lugar onde devo colocar scripts que exijam IPv6? Existem muitas respostas que sugerem que if-up.d é o local correto?

Estou usando o Raspbian Jessie Lite, que já tem Slow Boot (um script em /etc/systemd/system/dhcpcd.service.d/wait.conf que aguarda o DHCP) que corrigiu problemas semelhantes anteriormente com coisas em execução antes de a rede estar pronta .

Eu incluí os registros de qualquer coisa, incluindo network / dhcp / eth0 abaixo.

Apr  6 20:49:58 raspberrypi systemd[1]: Starting LSB: Raise network interfaces....
Apr  6 20:49:58 raspberrypi networking[223]: Configuring network interfaces...* Hostname was NOT found in DNS cache
Apr  6 20:49:58 raspberrypi networking[223]: % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Apr  6 20:49:58 raspberrypi networking[223]: Dload  Upload   Total   Spent    Left  Speed
Apr  6 20:49:58 raspberrypi networking[223]: 0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Could not resolve host: dynv6.com
Apr  6 20:49:58 raspberrypi networking[223]: * Closing connection 0
Apr  6 20:49:58 raspberrypi networking[223]: curl: (6) Could not resolve host: dynv6.com
Apr  6 20:49:58 raspberrypi networking[223]: done.
Apr  6 20:49:58 raspberrypi systemd[1]: Started LSB: Raise network interfaces..
Apr  6 20:49:58 raspberrypi systemd[1]: Starting dhcpcd on all interfaces...
Apr  6 20:49:58 raspberrypi dhcpcd[385]: version 6.7.1 starting
Apr  6 20:49:58 raspberrypi dhcpcd[385]: dev: loaded udev
Apr  6 20:49:58 raspberrypi dhcpcd[385]: eth0: adding address fe80::1073:c87:ef15:c4a3
Apr  6 20:49:58 raspberrypi dhcpcd[385]: eth0: waiting for carrier
Apr  6 20:49:58 raspberrypi dhcpcd[385]: wlan0: waiting for carrier
Apr  6 20:50:00 raspberrypi dhcpcd[385]: eth0: carrier acquired
Apr  6 20:50:00 raspberrypi dhcpcd[385]: DUID 00:01:00:01:1e:7e:75:f4:b8:27:eb:8c:48:b0
Apr  6 20:50:00 raspberrypi dhcpcd[385]: eth0: IAID eb:8c:48:b0
Apr  6 20:50:01 raspberrypi dhcpcd[385]: eth0: rebinding lease of 192.168.0.100
Apr  6 20:50:01 raspberrypi dhcpcd[385]: eth0: soliciting an IPv6 router
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: Router Advertisement from fe80::c23e:fff:fe63:5170
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: adding address fd41:6d80:6364:0:bcdf:ae43:354b:1e46/64
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: adding address 2a02:c7d:2bbb:9f00:76b3:47f9:2c11:fea4/64
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: adding route to fd41:6d80:6364::/64
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: adding route to 2a02:c7d:2bbb:9f00::/64
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: adding default route via fe80::c23e:fff:fe63:5170
Apr  6 20:50:02 raspberrypi dhcpcd[385]: eth0: requesting DHCPv6 information
Apr  6 20:50:06 raspberrypi dhcpcd[385]: eth0: leased 192.168.0.100 for 86400 seconds
Apr  6 20:50:06 raspberrypi dhcpcd[385]: eth0: adding route to 192.168.0.0/24
Apr  6 20:50:06 raspberrypi dhcpcd[385]: eth0: adding default route via 192.168.0.1
Apr  6 20:50:06 raspberrypi dhcpcd[385]: forked to background, child pid 716
Apr  6 20:50:06 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
Apr  6 20:50:06 raspberrypi ntpd[757]: Listen normally on 3 eth0 192.168.0.100 UDP 123
Apr  6 20:50:06 raspberrypi ntpd[757]: Listen normally on 5 eth0 2a02:c7d:2bbb:9f00:76b3:47f9:2c11:fea4 UDP 123
Apr  6 20:50:06 raspberrypi ntpd[757]: Listen normally on 6 eth0 fe80::1073:c87:ef15:c4a3 UDP 123
Apr  6 20:50:06 raspberrypi ntpd[757]: Listen normally on 8 eth0 fd41:6d80:6364:0:bcdf:ae43:354b:1e46 UDP 123
    
por Danny Tuppeny 06.04.2016 / 23:12

1 resposta

2

Seu script if-up.d será executado mais de uma vez. A variável $ ADDRFAM será definida como " inet " e " inet6 " respectivamente para quando o IPv4 e o IPv6 estiverem configurados. Verifique esta variável no seu script, se estiver usando o bash:

[ "$ADDRFAM" == "inet6" ] || exit 0

(Nota: isso acontece se você tiver um endereço IPv6 estático configurado, possivelmente não usando SLAAC ou DHCPv6, eu não testei)

    
por 06.04.2016 / 23:36