How to redirect domain A to domain B

If you really wanted to redirect a domain with only DNS records and are OK with third-party services, you may use forwarddomain.net.

It works by setting your source domain (e.g. www.olddomain.com) CNAME to r.forwarddomain.net (or A+AAAA records of that) and set the target domain URL by writing a TXT record with _ prefix (e.g. _.www.olddomain.com) to that domain with forward-domain= prefix (e.g. forward-domain=https://newdomain.net). The full DNS record will be:

www.olddomain.net.      IN  CNAME  r.forwarddomain.net
_.www.olddomain.net.    IN  TXT    forward-domain=https://newdomain.net/*

That will redirect www.olddomain.net to newdomain.net, also works with HTTPS.