Konfigurieren des Raspberry Pi als DHCP / lokaler DNS-Server, Stretch vs Wheezy

694
Mark Olbert

Ich habe dnsmasq als DHCP-Server / Resolver auf einem alten Raspberry Pi verwendet, auf dem Wheezy seit Jahren ohne Probleme läuft. Ich entschied mich für ein Upgrade auf Stretch und gleichzeitig auf einen Raspberry Pi 3B +.

Leider habe ich Probleme mit der Konfiguration des neuen Pi, um dieselben DHCP- und DNS-Dienste wie der alte Pi bereitzustellen. Ich benutze dnsmasq für beide Dienste. Ich kann den neuen Pi so konfigurieren, dass er ordnungsgemäß funktioniert, wenn er nicht auch DHCP / DNS-Dienste bereitstellt und stattdessen diese vom alten Pi bezieht. Aber wenn ich versuche, diese Dienste bereitzustellen, verliere ich meine Verbindung zum Internet. Es fühlt sich an, als habe ich die Konfiguration des Gateways versaut, obwohl ich nicht weiß, wie, und die Diagnose, die ich ausführen kann, scheint kein Problem mit dem Gateway zu zeigen.

Auf dem alten Pi, bei dem Wheezy ausgeführt wird, habe ich die Ethernet-Schnittstelle in / etc / network / interfaces wie folgt konfiguriert:

iface eth0 inet static address 10.0.0.4 netmask 255.255.255.0 gateway 10.0.0.2 

Auf dem neuen Pi, auf dem Stretch ausgeführt wird, konfiguriere ich die Ethernet-Schnittstelle in dhcpcd.conf (Beachten Sie, dass ich hier eine andere statische IP-Adresse verwende, so dass die beiden Geräte nicht kollidieren, während ich versuche, den Übergang zur IP-Adresse zu bewirken neues Gerät):

interface eth0 static ip_address=10.0.0.5/24 static routers=10.0.0.2 

Wenn ich das neue Pi als eigenständiges Gerät ausführe, kommentiere ich diese drei Zeilen aus, da das neue Pi seine IP-Adresse vom alten Pi erhält.

Während des Startvorgangs scheint der Boot-Prozess sowohl resolvconf als auch dhcpcd zu umfassen, indem er /etc/resolv.conf umschreibt. Resolvconf erstellt außerdem eine separate resolv.conf -Datei unter /run/dnsmasq/resolv.conf...und die beiden sind nicht identisch. Ich verstehe auch nicht, warum es zwei separate Dateien gibt und welche Rolle sie jeweils spielen.

Hier ist /etc/resolv.conf nach einem boot:

# Generated by resolvconf nameserver 127.0.0.1 # external nameservers nameserver 8.8.8.8 nameserver 8.8.4.4 

Hier ist /run/dnsmasq/resolv.conf:

# Generated by resolvconf 

Hier sind resolvconf.conf:

# Configuration for resolvconf(8) # See resolvconf.conf(5) for details  resolv_conf=/etc/resolv.conf # If you run a local name server, you should uncomment the below line and # configure your subscribers configuration files below. name_servers=127.0.0.1, 8.8.8.8, 8.8.4.4  # Mirror the Debian package defaults for the below resolvers # so that resolvconf integrates seemlessly. dnsmasq_resolv=/var/run/dnsmasq/resolv.conf pdnsd_conf=/etc/pdnsd.conf unbound_conf=/var/cache/unbound/resolvconf_resolvers.conf 

resolv.conf.tail:

# external nameservers nameserver 8.8.8.8 nameserver 8.8.4.4 

und dhcpcd.conf:

# A sample configuration for dhcpcd. # See dhcpcd.conf(5) for details.  # Allow users of this group to interact with dhcpcd via the control socket. #controlgroup wheel  # Inform the DHCP server of our hostname for DDNS. hostname  # Use the hardware address of the interface for the Client ID. clientid # or # Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361. # Some non-RFC compliant DHCP servers do not reply with this set. # In this case, comment out duid and enable clientid above. #duid  # Persist interface configuration when dhcpcd exits. persistent  # Rapid commit support. # Safe to enable by default because it requires the equivalent option set # on the server to actually work. option rapid_commit  # A list of options to request from the DHCP server. option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes # Most distributions have NTP support. option ntp_servers # Respect the network MTU. This is applied to DHCP routes. option interface_mtu  # A ServerID is required by RFC2131. require dhcp_server_identifier  # Generate Stable Private IPv6 Addresses instead of hardware based ones slaac private  # A list of options to request from the DHCP server. option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes # Most distributions have NTP support. option ntp_servers # Respect the network MTU. This is applied to DHCP routes. option interface_mtu  # A ServerID is required by RFC2131. require dhcp_server_identifier  # Generate Stable Private IPv6 Addresses instead of hardware based ones slaac private  # This section needs to be live if mycroft is serving as # the DHCP server for the LAN. Conversely, if it isn't # serving in that role, it needs to be commented out. interface eth0 static ip_address=10.0.0.5/24 static routers=10.0.0.2 #static domain_name_servers=127.0.0.1,8.8.8.8,8.8.4.4  # not using ip6! #static ip6_address=fd51:42f8:caae:d92e::ff/64  # domain name servers specified in resolv.conf.tail #static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1  # It is possible to fall back to a static IP if DHCP fails: # define static profile #profile static_eth0 #static ip_address=192.168.1.23/24 #static routers=192.168.1.1 #static domain_name_servers=192.168.1.1  # fallback to static profile on eth0 #interface eth0 #fallback static_eth0 

Vorschläge?

0
Wheezy verwendet sysvinit, Stretch verwendet systemd, wodurch einige netzwerkbezogene Aufgaben automatisiert werden. Ipor Sircer vor 5 Jahren 0
Danke, @IporSircer; Das ist eine andere Lernkurve, die ich versuche, herunterzukommen. Irgendwelche Gedanken, was ich in der Konfiguration falsch mache? Mark Olbert vor 5 Jahren 0
Ich denke, Ihre Konfiguration ist in Ordnung, nur systemd und sein Netzwerkmanager denken, dass sie intelligenter sind als Sie. (Ich benutze kein Systemd, ich hatte andere seltsame Fehler damit.) Ipor Sircer vor 5 Jahren 0
Lol! Im Moment bin ich mir sicher, dass es klüger ist als ich. Mark Olbert vor 5 Jahren 0

0 Antworten auf die Frage