DHCP and DNS

DHCP

Client

Check wether we use systemd-networkd or NetworkManager

networkctl status
journalctl -u NetworkManager.service | grep DHCP

Check lease

systemd-netword:

cat /var/lib/dhclient/*.lease

Remove old leases and request new offer:

dhclient -r -v eth0 && rm /var/lib/dhcp/dhclient.* ; dhclient -v eth0

NetworkManager

cat /var/lib/NetworkManager/*.lease 

DNS

Debugging

dig @name-server.fqdn record-name.to.lookup

systemctl is-active systemd-resolved
systemctl is-active named # bind9
resolvectl status
systemd-resolve --status
less /etc/resolve.conf

sudo resolvectl flush-caches
sudo systemd-resolve --flush-chaches

nsupdate

https://www.rfc-editor.org/rfc/rfc2136

sudo apt install bind9-dnsutils

Add key file ./.key:

key "<your domain>.fqdn.key" {
  algorithm hmac-sha512;
  secret "<key>";
};

Connect vis nsupdate

nsupdate -k ./<domain>.key

Connect to the nameserver in the opened prompt:

> server <name-server>.fqdn
>

Add a CNAME:

  • "cname.to.add.fqdn.": CNAME/alias to add.
  • "3600": TTL in seconds (not hops).
  • "CNAME": Record Type.
  • "target.to.point.to.fqdn.": Target where the cname should point to.
> update add cname.to.add.fqdn. 3600 CNAME target.to.point.to.fqdn.
> show
> send

Delete a record:

> update delete name.to.delete.fqdn.
> show
> send

Use eg dig to confirm new cname.