xcp-ng / xcp

Entry point for issues and wiki. Also contains some scripts and sources.
https://xcp-ng.org
1.32k stars 74 forks source link

/etc/resolv.conf not written when primary-address-type=IPv6 #641

Open mas90 opened 8 months ago

mas90 commented 8 months ago

If I set primary-address-type=IPv6 on my management PIF (with both IPv6 (autoconf) and IPv4 (static) addresses configured, and with both IPv6 and IPv4 DNS servers configured on the PIF), /etc/resolv.conf doesn't contain any nameservers.

This happens both on XCP-ng 8.3 beta 2 and on the latest 8.3 CI packages (i.e. after "yum --enablerepo=xcp-ng-candidates,xcp-ng-testing,xcp-ng-ci update").

root@sleat:~$ xe host-management-disable && xe pif-set-primary-address-type uuid=f19d84b1-1802-ae06-8467-6c74a97a2852 primary_address_type=IPv4 ; xe host-management-reconfigure pif-uuid=f19d84b1-1802-ae06-8467-6c74a97a2852
root@sleat:~$ cat /etc/resolv.conf
nameserver 192.168.0.1
nameserver 2a05:xxxx:xxxx::1
root@sleat:~$ xe host-management-disable && xe pif-set-primary-address-type uuid=f19d84b1-1802-ae06-8467-6c74a97a2852 primary_address_type=IPv6 ; xe host-management-reconfigure pif-uuid=f19d84b1-1802-ae06-8467-6c74a97a2852
root@sleat:~$ cat /etc/resolv.conf

root@sleat:~$ xe pif-param-list uuid=f19d84b1-1802-ae06-8467-6c74a97a2852
uuid ( RO)                       : f19d84b1-1802-ae06-8467-6c74a97a2852
                     device ( RO): eth0
                        MAC ( RO): fe:ff:ff:ff:ff:ff
                   physical ( RO): false
                    managed ( RO): true
         currently-attached ( RO): true
                        MTU ( RO): 1500
                       VLAN ( RO): 0
             vlan-master-of ( RO): b04e6ed9-f9e0-fb26-f8e6-1e52f9db33c4
              vlan-slave-of ( RO):
             bond-master-of ( RO):
              bond-slave-of ( RO): <not in database>
      sriov-physical-PIF-of ( RO):
       sriov-logical-PIF-of ( RO):
       tunnel-access-PIF-of ( RO):
    tunnel-transport-PIF-of ( RO):
                 management ( RO): true
               network-uuid ( RO): 9f23636d-7eef-5374-db6c-7c101a004a89
         network-name-label ( RO): VLAN 1
                  host-uuid ( RO): f9dbd676-4b4a-4479-b94e-5f183cc0af05
            host-name-label ( RO): sleat
      IP-configuration-mode ( RO): Static
                         IP ( RO): 192.168.0.21
                    netmask ( RO): 255.255.252.0
                    gateway ( RO): 192.168.0.1
    IPv6-configuration-mode ( RO): Autoconf
                       IPv6 ( RO): fe80::3281:11ff:fe07:459/64; 2a05:xxxx:xxxx:0:3281:11ff:fe07:459/64
               IPv6-gateway ( RO): fe80::7c59:5dff:fe53:c448
       primary-address-type ( RO): IPv6
                        DNS ( RO): 192.168.0.1,2a05:xxxx:xxxx::1
                 properties (MRO):
               capabilities (SRO):
                io_read_kbs ( RO): 1.062
               io_write_kbs ( RO): 0.676
                    carrier ( RO): true
                  vendor-id ( RO): 10ec
                vendor-name ( RO): Realtek Semiconductor Co., Ltd.
                  device-id ( RO): 8168
                device-name ( RO): RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
                      speed ( RO): 1000 Mbit/s
                     duplex ( RO): full
            disallow-unplug ( RW): false
               pci-bus-path ( RO): 0000:01:00.0
               other-config (MRW):
       igmp-snooping-status ( RO): unknown
benjamreis commented 8 months ago

Hi!

I think it's due to the Autoconf, like for DHCP the resolv file is probably overwritten by what's received via SLAAC, but there's no DNS given. Can you try to configure the IPv6 statically? AFAIK Autoconf should also provide a DNS as well.

Thanks.

mas90 commented 8 months ago

Hi @benjamreis

I think it's due to the Autoconf, like for DHCP the resolv file is probably overwritten by what's received via SLAAC, but there's no DNS given. Can you try to configure the IPv6 statically? AFAIK Autoconf should also provide a DNS as well.

My router does advertise a DNS server, both via SLAAC and via stateless DHCPv6, but that DNS server doesn't seem to ever be added to /etc/resolv.conf.

But you're right that if I configure the IPv6 address statically, /etc/resolv.conf does get written correctly. So the problem may be related to autoconf, but autoconf isn't writing any nameservers even if the network advertises them.

benjamreis commented 8 months ago

Thx for the report! I'll look into it!

benjamreis commented 8 months ago

Hi @mas90, I have a potential fix, would you be interested in testing it? If so please add a new file in /etc/yum.repo.d named xcp-ng-brs.repo. Then put in it:

[xcp-ng-u-brs2]
name=XCP-ng User BRS 2 Repository
baseurl=https://koji.xcp-ng.org/repos/user/8/8.3/brs2/x86_64/
enabled=0
gpgcheck=1
repo_gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng

This will add one of my test repo to your yum config (disabled by default of course) Then run yum update xapi-core --enablerepo=xcp-ng-u-brs2 this will update the XAPI with my fix and with it th DNs should be writen to the resolv file.

If you're okay doing it, please report here the result! Thank you!

mas90 commented 8 months ago

Hi @benjamreis, thanks for this! After installing your fix then changing IPv6-configuration-mode back to Autoconf (I had temporarily set it to static as a workaround), for some reason my existing IPv6 DNS server was lost from the configuration but my IPv4 DNS server was successfully added to resolv.conf. After I put my IPv6 DNS server back (xe pif-reconfigure-ipv6 ... DNS=...), both IPv6 and IPv4 DNS servers are in resolv.conf.

So it looks like you successfully fixed the problem, as far as I am concerned :) Except perhaps for the DNS setting being lost initially after update.

benjamreis commented 8 months ago

Hmm it looks I fix part of it but if you're router advertise DNS with SLAAC it should have been configured without manually specifying it via cli right?

mas90 commented 8 months ago

If the intent was to support DNS autoconfiguration via SLAAC, then indeed that seems still not to be working. Static DNS is working after your fix. It would be good to have autoconfiguration working, but at least I can now have working DNS somehow :-)

mas90 commented 8 months ago

I tested this fix on two systems, and just discovered that after leaving both of them running for a week or so (with IPv6-configuration-mode=Autoconf, but a static IPv6 DNS server) the IPv6 DNS server has vanished from /etc/resolv.conf leaving only the IPv4 one...

smrqdt commented 7 months ago

I believe I’m hitting the same (or a similar?) problem with slightly different settings on 8.3 beta 2 and the CI packages:

4dcb3  fiddlers-green ~]# xe pif-param-list uuid=bd19e8f3-db8d-54a2-bb3d-b4941484
uuid ( RO)                       : bd19e8f3-db8d-54a2-bb3d-b4941484dcb3
                     device ( RO): eth0
                        MAC ( RO): fe:ff:ff:ff:ff:ff
                   physical ( RO): false
                    managed ( RO): true
         currently-attached ( RO): true
                        MTU ( RO): 1500
                       VLAN ( RO): 131
             vlan-master-of ( RO): 67926b17-e6da-da3a-03d1-d93179b943ea
              vlan-slave-of ( RO): 
             bond-master-of ( RO): 
              bond-slave-of ( RO): <not in database>
      sriov-physical-PIF-of ( RO): 
       sriov-logical-PIF-of ( RO): 
       tunnel-access-PIF-of ( RO): 
    tunnel-transport-PIF-of ( RO): 
                 management ( RO): true
               network-uuid ( RO): 95981197-ed76-5b07-3a92-a3e368fca191
         network-name-label ( RO): Pool-wide network associated with eth0 on VLAN131
                  host-uuid ( RO): 644931d6-8604-48e3-b370-6874d40391ef
            host-name-label ( RO): fiddlers-green
      IP-configuration-mode ( RO): DHCP
                         IP ( RO): 10.11.131.9
                    netmask ( RO): 255.255.255.0
                    gateway ( RO): 10.11.131.1
    IPv6-configuration-mode ( RO): Autoconf
                       IPv6 ( RO): fe80::fab4:6aff:feac:b6d9/64; 2a02:8106:0:6983:fab4:6aff:feac:b6d9/64
               IPv6-gateway ( RO): fe80::de2c:6eff:fe66:305b
       primary-address-type ( RO): IPv4
                        DNS ( RO): 10.11.131.1
                 properties (MRO): 
               capabilities (SRO): 
                io_read_kbs ( RO): 0.932
               io_write_kbs ( RO): 0.000
                    carrier ( RO): true
                  vendor-id ( RO): 10ec
                vendor-name ( RO): Realtek Semiconductor Co., Ltd.
                  device-id ( RO): 8168
                device-name ( RO): RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
                      speed ( RO): 1000 Mbit/s
                     duplex ( RO): full
            disallow-unplug ( RW): false
               pci-bus-path ( RO): 0000:05:00.0
               other-config (MRW): 
       igmp-snooping-status ( RO): unknown

After boot, for a short time the resolv.conf looks fine containing the IPv4 DNS server obtained through DHCP (; generated by /usr/sbin/dhclient-script), but is then overwritten by an empty file (containing only a newline). The router advertises the DNS via SLAAC, no DHCPv6. I could live with only v4 DNS, but it seems the broken v6 auto configuration ruins that too.

(If this is a different issue, I can open a new issue.)

smrqdt commented 4 months ago

Issue persists with 8.3 RC1 (after yum update and reboot)