Chris Davies wrote: > Fails for CNAME chains, sorry! > > $ dig +short www.bbc.co.uk > www.bbc.net.uk. > 212.58.246.94 > > (You could try dig +short ... | grep -v '\.$', but I've not tested that > exhaustively.)
You might use the bind9-host 'host' command. $ host www.bbc.co.uk www.bbc.co.uk is an alias for www.bbc.net.uk. www.bbc.net.uk has address 212.58.246.93 Which means this works easily for IPv4 addresses. $ host www.bbc.co.uk | awk '/has address/{print$NF}' 212.58.246.93 For IPv6 addresses with 'host' you would need this: $ host www.debian.org www.debian.org has address 206.12.19.7 www.debian.org has address 128.31.0.51 www.debian.org has IPv6 address 2607:f8f0:610:4000:211:25ff:fec4:5b28 $ host www.debian.org | awk '/has.*address/{print$NF}' 128.31.0.51 206.12.19.7 2607:f8f0:610:4000:211:25ff:fec4:5b28 Or 'getent' was already mentioned. All of this makes me curious as to why Tong needed to get the IP address in the first place. :-} Bob
signature.asc
Description: Digital signature