Gibt es einen Linux-Befehl zum Übersetzen des Domainnamens in IP?
Gibt es einen Linux-Befehl zum Übersetzen des Domainnamens in IP?
Antworten:
% dig +short stackoverflow.com
69.59.196.211
oder
% host stackoverflow.com
stackoverflow.com has address 69.59.196.211
stackoverflow.com mail is handled by 30 alt2.aspmx.l.google.com.
stackoverflow.com mail is handled by 40 aspmx2.googlemail.com.
stackoverflow.com mail is handled by 50 aspmx3.googlemail.com.
stackoverflow.com mail is handled by 10 aspmx.l.google.com.
stackoverflow.com mail is handled by 20 alt1.aspmx.l.google.com.
bind-toolsPaket.
basename $(dig +short stackoverflow.com A | tr '\n' '/') instead. This is useful when you want to get-IP-by-domain in shell scripts.
You can use:
nslookup www.example.com
nslookup is less ideal for scripting. dig +short is probably the most correct answer here, as already suggested by @unutbu.
dig and host are installed by default on all distros, meanwhile nslookup is part of busybox, the base of lightweight distos like Alpine.
www.
www.example.comund example.comkann auf verschiedene IP-Adressen verweisen.
nslookupist veraltet ist, aber ich ziehe immer noch seine Ausgabeformat über dig +shortund hostfür die menschliche Lesbarkeit.