Name resolution issues

Issues related to configuring your network
Post Reply
bodisha
Posts: 52
Joined: 2015/06/06 23:55:29

Name resolution issues

Post by bodisha » 2020/08/11 17:15:58

I need to figure out how to configure a Linux 7 machine to resolve the src IP address to their hostnames with the "ip -r route" command. Here's the output of the ip command both with and without the '-r' option

Code: Select all

[root@centos7lab ~]# ip -r route
default via gateway dev enp0s3 proto dhcp metric 100
192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.137 metric 100
192.168.2.0/24 dev enp0s8 proto kernel scope link src 192.168.2.10 metric 101
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
[root@centos7lab ~]# ip route
default via 192.168.1.1 dev enp0s3 proto dhcp metric 100
192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.137 metric 100
192.168.2.0/24 dev enp0s8 proto kernel scope link src 192.168.2.10 metric 101
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
As you can see... With the exception of 192.168.1.1 (gateway)... None of the IP addresses in the src field are resolving out to their hostnames in the /etc/host file

Code: Select all

[root@centos7lab ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.10 centos7lab centos7lab.videos.org
192.168.1.137 centos7lab1 centos7lab1.videos.org
192.168.2.1  router1 router1.videos.org
I've configured DNS and I can resolve them using nslookup

Code: Select all

[root@centos7lab ~]# nslookup centos7lab
Server:         192.168.2.10
Address:        192.168.2.10#53

Name:   centos7lab.videos.org
Address: 192.168.2.10

[root@centos7lab ~]# nslookup 192.168.2.10
10.2.168.192.in-addr.arpa       name = centos7lab.videos.org.

[root@centos7lab ~]#

But when I try using dig the name resolution seems to fail

Code: Select all

[root@centos7lab ~]# dig centos7lab

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 <<>> centos7lab
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 5493
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;centos7lab.                    IN      A

;; AUTHORITY SECTION:
.                       10800   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2020081100 1800 900 604800 86400

;; Query time: 66 msec
;; SERVER: 192.168.2.10#53(192.168.2.10)
;; WHEN: Tue Aug 11 12:19:50 CDT 2020
;; MSG SIZE  rcvd: 114

[root@centos7lab ~]# dig 192.168.2.10

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-16.P2.el7_8.6 <<>> 192.168.2.10
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 20815
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;192.168.2.10.                  IN      A

;; AUTHORITY SECTION:
.                       3097    IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2020081100 1800 900 604800 86400

;; Query time: 0 msec
;; SERVER: 192.168.2.10#53(192.168.2.10)
;; WHEN: Tue Aug 11 12:21:10 CDT 2020
;; MSG SIZE  rcvd: 116


Can someone point me in the right direction and set me straight on how to set up name resolution for the "ip -r route" command? I appreciate it!
Last edited by bodisha on 2020/08/11 22:08:25, edited 2 times in total.

BShT
Posts: 278
Joined: 2019/10/09 12:31:40

Re: Name resolution issues

Post by BShT » 2020/08/11 18:12:19

dnsmasq honors /etc/hosts

bind no, you have to create zones, etc

bodisha
Posts: 52
Joined: 2015/06/06 23:55:29

Re: Name resolution issues

Post by bodisha » 2020/08/11 19:40:17

I'm unsure what part dnsmasq play's into the "ip -r route" command resolving a hostname... Could I ask you to expound on that? And I have zones configured in my /etc/named.rfc1912.zones file

Code: Select all

zone "videos.org" IN {
        type master;
        file "named.localhost";
        allow-update { none; };
};

 cat /var/named/named.localhost
$TTL 1D
@       IN SOA  centos7lab.videos.org. root.videos.org. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      centos7lab.videos.org.
        A       192.168.2.10
centos7lab      A       192.168.2.10
centos7lab1     A       192.168.1.137
router1 A      192.168.2.1

Code: Select all

zone "2.168.192.in-addr.arpa" IN {
        type master;
        file "named.reverse";
        allow-update { none; };
};


[root@centos7lab ~]# cat /var/named/named.reverse
$TTL 1D
@       IN SOA  centos7lab.videos.org. root.videos.org. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      centos7lab.videos.org.
        PTR     videos.org.
        A       192.168.2.10
centos7lab      A       192.168.2.10
router1 A      192.168.2.1
10      PTR     centos7lab.videos.org.
1       PTR     router1.videos.org.



User avatar
TrevorH
Forum Moderator
Posts: 29493
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Name resolution issues

Post by TrevorH » 2020/08/11 19:47:13

I think you're expecting it to do more than it does and it doesn't. There are some things in the ip ro output that look a bit like ip addresses but are not, they are subnets and thus are not something you can reverse lookup - like 192.168.1.0/24. The only other place it has an ip address is in the 'src' and it never translates that. So in your ip route output, you only have one ip that it can resolve and it already does: 'gateway'.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

bodisha
Posts: 52
Joined: 2015/06/06 23:55:29

Re: Name resolution issues

Post by bodisha » 2020/08/11 21:47:08

Thx for the reply... But no, I'm not talking about the subnet mask. I'm talking about the src field which is the IP address associated with the interface.

The ip man page states
-r, -resolve
use the system's name resolver to print DNS names instead of host addresses.
And I've seen screenshots of the output of "ip -r route" and the IP Addresses in the src field has been resolved to their hostnames. So I'm certain it's possible.

I suspect whatever reason is preventing the dig utility from resolving IP addresses is causing the resolve option in the ip command to fail.

User avatar
TrevorH
Forum Moderator
Posts: 29493
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Name resolution issues

Post by TrevorH » 2020/08/11 22:21:42

The dig command doesn't look at /etc/hosts at all which is why that does not work. That was why dnsmasq was suggested, so that you could use a dns server that does look at /etc/hosts and serve its contents to client lookups.

I am pretty sure that the ip route command just does not translate the src address to a name since I ran it here on a fully updated Fedora 32 system with a working reverse DNS and it does not do so here. I'm not using /etc/hosts, I have a working dns system that is quite happy to reverse lookup the src ips and resolve them correctly. But not via ip -r ro. Nor does it work on my Debian Buster system. Or a CentOS 7 system or one running 8. On all of those I can run host ip.add.re.ss where ip.add.re.ss is the ip address listed as the src in ip -r ro and it does resolve it to a name. The ip -r ro command does not.

I've tested Fedora 32, Debian 10, CentOS 6, CentOS 7 and CentOS 8 and they all work the way I think it should work and none of them work the way you think it should.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

bodisha
Posts: 52
Joined: 2015/06/06 23:55:29

Re: Name resolution issues

Post by bodisha » 2020/08/12 03:18:17

Thanks... I appreciate it it!

Post Reply

Return to “CentOS 7 - Networking Support”