![]() What about dual-stack hostnames: $ host has address 66.220.153.15 Where the hostname is an IPv6-only hostname. More than multiple IP addresses and aliases, is there some other special cases. I did not find any example where a hostname resolves to an alias that does not resolve to an IP address, but I think the case might occur. $ host is an alias for is an alias for has address 74.125.39.147 Of course, the case where an alias has a single IP address is possible, as shown below: $ host g.g.is an alias for address 207.46.19.190īut can aliases be chained? The answer is yes: $ host is an alias for an alias for g.g.is an alias for address 207.46.19.254 For more information on aliases, check here. So does not directly resolve to IP addresses, but to an alias that itself resolves to multiple IP addresses. Let's check the example below: $ host is an alias for has address 74.125.39.103 Below, an example with a hostname resolving to more than a single IP address: $ host has address 209.85.148.147īut what is This is where the alias case needs to be introduced. ![]() In this case (and others below), basic scripting under the assumption that a hostname directly resolves to a single IP address may break. This might be the only case where you need to resolve hostnames, but if not, below is a discussion on some cases that you might need to handle.Ĭhris Down and Heinzi briefly discussed the case where the hostname resolves to more than one IP addresses. The solutions given so far mostly work in the simpler case: the hostname directly resolves to a single IPv4 address. This resolves using gethostbyaddr/gethostbyname2, and so also will check /etc/hosts/NIS/etc: getent hosts | awk '' You can use getent, which comes with glibc (so you almost certainly have it on Linux).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |