DNS resolving for "gateway"
DNS resolving for "gateway"
Hello community,
can I kindly share with you this following issue please. We experience a problem with this feature.
if from terminal i type:
ping gateway
[root@xxx ~]# ping gateway
PING gateway (10.3.6.1) 56(84) bytes of data.
64 bytes from gateway (10.3.6.1): icmp_seq=1 ttl=255 time=0.746 ms
64 bytes from gateway (10.3.6.1): icmp_seq=2 ttl=255 time=0.828 ms
64 bytes from gateway (10.3.6.1): icmp_seq=3 ttl=255 time=0.803 ms
it returns the IP of my set gateway no matter if the "gateway" is in my DNS server or not. I am using CentOS Linux release 7.9.2009 (Core).
If I try the same on this following system it does not work: CentOS Stream release 8
[root@yyy ~]# ping gateway
ping: gateway: Name or service not known
So the desired behavior is not to have the word gateway translated to the set "default gateway".
Does anyone have any clue why it acts this way and if so, how to turn it off please?
Thanks in advance.
David
can I kindly share with you this following issue please. We experience a problem with this feature.
if from terminal i type:
ping gateway
[root@xxx ~]# ping gateway
PING gateway (10.3.6.1) 56(84) bytes of data.
64 bytes from gateway (10.3.6.1): icmp_seq=1 ttl=255 time=0.746 ms
64 bytes from gateway (10.3.6.1): icmp_seq=2 ttl=255 time=0.828 ms
64 bytes from gateway (10.3.6.1): icmp_seq=3 ttl=255 time=0.803 ms
it returns the IP of my set gateway no matter if the "gateway" is in my DNS server or not. I am using CentOS Linux release 7.9.2009 (Core).
If I try the same on this following system it does not work: CentOS Stream release 8
[root@yyy ~]# ping gateway
ping: gateway: Name or service not known
So the desired behavior is not to have the word gateway translated to the set "default gateway".
Does anyone have any clue why it acts this way and if so, how to turn it off please?
Thanks in advance.
David
Re: DNS resolving for "gateway"
When you type ping gateway your machine has to resolve the name "gateway" into an IP address.
Then ping will use that IP address.
How does one resolve? On my machine:
System first looks from "files" and then asks from DNS server.
The "files" is /etc/hosts. If it has entry for "gateway", then that is used.
If system has to ask from DNS server, then whom does it ask from?
It starts with the first "nameserver" that is in /etc/resolv.conf
None of that is directly related to the router(s) that the subnet(s) has.
Then ping will use that IP address.
How does one resolve? On my machine:
Code: Select all
$ grep ^hosts /etc/nsswitch.conf
hosts: files dns myhostname
The "files" is /etc/hosts. If it has entry for "gateway", then that is used.
If system has to ask from DNS server, then whom does it ask from?
It starts with the first "nameserver" that is in /etc/resolv.conf
None of that is directly related to the router(s) that the subnet(s) has.
Re: DNS resolving for "gateway"
Hello,
thank you for your reply. I understand the process of the lookup. The thing I dont understand is why on CentOS 7 this following works:
But there is no "gateway" in hosts file, nor is it in any configured DNS server.
So how does it translate the word "gateway" to the IP address of my set default gateway?
David
thank you for your reply. I understand the process of the lookup. The thing I dont understand is why on CentOS 7 this following works:
Code: Select all
[root@xxx]# ping gateway
PING gateway (10.2.9.1) 56(84) bytes of data.
64 bytes from gateway (10.2.9.1): icmp_seq=1 ttl=255 time=0.797 ms
64 bytes from gateway (10.2.9.1): icmp_seq=2 ttl=255 time=0.875 ms
64 bytes from gateway (10.2.9.1): icmp_seq=3 ttl=255 time=0.884 ms
64 bytes from gateway (10.2.9.1): icmp_seq=4 ttl=255 time=0.803 ms
So how does it translate the word "gateway" to the IP address of my set default gateway?
David
Re: DNS resolving for "gateway"
Hello,
this is output from dig command from Centos 7 where gateway resolves to ip address:
this is output from dig command from Centos 8 where gateway does not resolve to anything:
Outputs are same, so I expect this being some "feature" of Centos 7, where it automatically resolves word "gateway" to set ip address of the default gateway.
David
this is output from dig command from Centos 7 where gateway resolves to ip address:
Code: Select all
[root@xxx]# dig gateway
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.4 <<>> gateway
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 11726
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;gateway. IN A
;; Query time: 0 msec
;; SERVER: 10.2.2.10#53(10.2.2.10)
;; WHEN: Wed Mar 24 09:41:01 CET 2021
;; MSG SIZE rcvd: 36
Code: Select all
[root@yyy]# dig gateway
; <<>> DiG 9.11.26-RedHat-9.11.26-3.el8 <<>> gateway
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 33423
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;gateway. IN A
;; Query time: 0 msec
;; SERVER: 10.2.2.10#53(10.2.2.10)
;; WHEN: Wed Mar 24 09:40:14 CET 2021
;; MSG SIZE rcvd: 36
David
Re: DNS resolving for "gateway"
It is not a feature of CentOS 7. It must be within your custom configuration somehow.
[EDIT] My mistake, it is a feature, as told below. I did not use correct setup/test to find it.
[EDIT] My mistake, it is a feature, as told below. I did not use correct setup/test to find it.
Last edited by jlehtone on 2021/04/06 19:31:58, edited 1 time in total.
Re: DNS resolving for "gateway"
It appears to be a feature of systemd-resolved.
Search for "gateway" on this page:
https://www.freedesktop.org/software/sy ... rvice.html
This page has a description of the same behavior, even when systemd-resolved is disabled:
https://askubuntu.com/questions/806778/ ... -change-it
Search for "gateway" on this page:
https://www.freedesktop.org/software/sy ... rvice.html
This page has a description of the same behavior, even when systemd-resolved is disabled:
https://askubuntu.com/questions/806778/ ... -change-it
Re: DNS resolving for "gateway"
Actually it's from the NSS myhostname module (https://www.freedesktop.org/software/sy ... tname.html) & (as noted in the above) it's actually _gateway, so not systemd-resolved....