How to add multiple IPv6 address for single host in /etc/hosts?

4

I want that a name should be resolved with multiple IPv6 addresses. I don't have access to a DNS server and I don't want to run a demon for that purpose.

I want to add the entry in /etc/hosts and it should return two IPv6 addresses for a single name.

theB

Posted 2012-08-02T06:46:39.373

Reputation: 181

Answers

8

Well, if you want to do that, just do so :-)

If you add this to /etc/hosts:

2001:db8::1 testing
2001:db8::2 testing
192.168.0.1 testing

then the hostname will have three addresses:

$ telnet testing
Trying 2001:db8::1...
Trying 2001:db8::2...
Trying 192.168.0.1...
telnet: Unable to connect to remote host: No route to host

In this case the addresses don't exist so the connection fails, but you can see that it works.

Sander Steffann

Posted 2012-08-02T06:46:39.373

Reputation: 4 169

I did the same. I gave link local address. I tried to ping them. Only the first address gets pinging. Acutally I want to check whether my machine is doing address select. So it is necessary to receive multiple A values for a particular name. – None – 2012-08-02T13:54:45.567

1Ping does get multiple addresses. It just chooses to always use the first one. If you want a different order then you will have to reorder /etc/hosts, or use something that does automatic shuffling like DNS – Sander Steffann – 2012-08-02T14:58:00.330

No. I want to ping to perform Default address selection (RFC3484) among all the addreses it receives before sending ICMP_REQUEST to the host. – None – 2012-08-03T05:01:40.867

1Then talk to the developers of ping – Sander Steffann – 2012-08-03T09:16:04.943

I am talking about ping6. Its already doing things correct. I don't know whether it is done by ping6 or the linux filters correct address from the list. But things works fine other than link local case. If destination has link local and global and source having link local and site local, my kernel prefers link locla dest with site local src. But accroding to RFC3484 it is wrong. – None – 2012-08-03T09:31:35.520

Then you should file a bug report... – Sander Steffann – 2012-08-04T07:05:11.073