# Hostname resolve on local network

## davidshen84

Hi,

My Gentoo is 64 bit, with systemd. I did not setup a local DNS service, neither did I configure my /etc/hosts for my system. But I found I can ping myself by using the host name directly. I wonder how the system resolved the hostname.

Also, I found it only works with ipv6, If I do ping6 <my host name>, it says "unknown host".

I use OpenWRT on my router. I found in the IPv4 DHCP lease table, it has my host name and ip listed. But in the IPv6 section, my system's host name is "?".

Do I need specific configuration to get hostname and ipv6 work together?

Thanks.

----------

## eccerr0r

1. Some routers do DNS by DHCP requested name.  It's a "nice" feature in some versions of router software (perhaps it's now a feature in dnsmasq) - for IPV4.

2. A lot of routers don't have DHCP6 set up properly and opt for using SLAAC.  Using SLAAC instead of DHCP6, then the router really has no idea what your IPV6 hostname is.

So it looks like you're using OpenWRT...unfortunately that's something I don't have much info about.  Oddly enough I currently know more about pfSense IPV6 than *WRT (i.e., Linux-based) IPV6 routing... ssshhh...

Granted just a hair more...

----------

## Syl20

 *davidshen84 wrote:*   

> But I found I can ping myself by using the host name directly. I wonder how the system resolved the hostname.

 

You can try a dig/nslookup request (net-dns/bind-tools). If the configured DNS server (probably your internet router/box) gives you the right answer, you know how.   :Wink: 

----------

## davidshen84

Hi Syl20,

Could you be more specific what am I suppose to look up? I tried dig as follow:

```
dig @fde4:c7f9:94a8::1 xps13 -6

; <<>> DiG 9.11.0-P3 <<>> @fde4:c7f9:94a8::1 xps13 -6

; (1 server found)

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65074

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 1280

;; QUESTION SECTION:

;xps13.                         IN      A

;; ANSWER SECTION:

xps13.                  0       IN      A       192.168.100.238

;; Query time: 2 msec

;; SERVER: fde4:c7f9:94a8::1#53(fde4:c7f9:94a8::1)

;; WHEN: Sun Mar 19 09:14:09 CST 2017

;; MSG SIZE  rcvd: 50

```

I queried my router using its ipv6 address, and I also provided the "-6" option, but the returned address is still ipv4 address. So I guess some ipv6 related configuration is mission on my laptop, or the router.

----------

## szatox

 *Quote:*   

> 
> 
> ;; ANSWER SECTION:
> 
> xps13.                  0       IN      A       192.168.100.238 

 

That's why you can ping your machine over ipv4 by name.

Your router's DNS did not provide ipv6 address for this name, so you need another way to discover your peers.

Good news is you can use avahi to achieve that. It uses multicast dns service for peer and service discovery, so every single node can introduce itself to the network instead of waiting for some authority to do that.

----------

## Ant P.

The downside of avahi is that instead of no response for IPv6, you'll get a segfault instead. (unless you install =sys-auth/nss-mdns-9999)

----------

