can ping by ip address but can not ping via hostname

Issues related to configuring your network
Post Reply
rahulvishwa1981
Posts: 5
Joined: 2019/10/26 07:56:47

can ping by ip address but can not ping via hostname

Post by rahulvishwa1981 » 2019/11/22 15:20:12

hi to all, i've centos6.10 in VM client and centos7.5 in server. i can ping from client via ipaddress only not by hostname. and i can not ping from server not by ipaddress and not by hostname.
from server to client :-

Code: Select all

[root@server75 named]# ping 192.168.20.4
PING 192.168.20.4 (192.168.20.4) 56(84) bytes of data.
From 192.168.20.1 icmp_seq=1 Destination Host Unreachable
From 192.168.20.1 icmp_seq=2 Destination Host Unreachable
From 192.168.20.1 icmp_seq=3 Destination Host Unreachable
From 192.168.20.1 icmp_seq=4 Destination Host Unreachable
^C
--- 192.168.20.4 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
from client to server :-

Code: Select all

[root@serverora11gr2 Desktop]# ping 192.168.20.4
PING 192.168.20.4 (192.168.20.4) 56(84) bytes of data.
64 bytes from 192.168.20.4: icmp_seq=1 ttl=64 time=0.810 ms
64 bytes from 192.168.20.4: icmp_seq=2 ttl=64 time=0.844 ms
^C
--- 192.168.20.4 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1221ms

User avatar
Errosion
Posts: 43
Joined: 2014/12/03 19:58:02

Re: can ping by ip address but can not ping via hostname

Post by Errosion » 2019/11/22 19:38:27

It looks like your second test is not a "client to server"

The server to client test, you ping 192.168.20.4. Implying that the client IP address is 192.168.20.4.
The client to server test, you ping 192.168.20.4. Which is actually client to client and should always work.

What is the server IP address?

That said, hostname resolution will only work if you have a DNS server set up to resolve the names accordingly or have manually inserted those resolutions into your /etc/hosts file.

rahulvishwa1981
Posts: 5
Joined: 2019/10/26 07:56:47

Re: can ping by ip address but can not ping via hostname

Post by rahulvishwa1981 » 2019/11/23 12:37:23

actually i am try to configure DNS on server ( 192.168.20.1 ). mine named.conf is :-

Code: Select all

options {
	listen-on port 53 { 127.0.0.1; 192.168.20.1; };
	#listen-on-v6 port 53 { ::1; };
	directory 	"/var/named";
	dump-file 	"/var/named/data/cache_dump.db";
	statistics-file "/var/named/data/named_stats.txt";
	memstatistics-file "/var/named/data/named_mem_stats.txt";
	allow-query     { localhost; 192.168.20.0/24; };

	/* 
	 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
	 - If you are building a RECURSIVE (caching) DNS server, you need to enable 
	   recursion. 
	 - If your recursive DNS server has a public IP address, you MUST enable access 
	   control to limit queries to your legitimate users. Failing to do so will
	   cause your server to become part of large scale DNS amplification 
	   attacks. Implementing BCP38 within your network would greatly
	   reduce such attack surface 
	*/
	recursion yes;

	dnssec-enable yes;
	dnssec-validation yes;

	/* Path to ISC DLV key */
	bindkeys-file "/etc/named.iscdlv.key";

	managed-keys-directory "/var/named/dynamic";

	pid-file "/run/named/named.pid";
	session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
	type hint;
	file "named.ca";
};

include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

zone "db.net" IN {
	type master;
	file "db.forward.zone";
	allow-update { none; };
};

zone "20.168.192.in-addr.arpa" IN {
	type master;
	file "db.reverse.zone";
	allow-update { none; };
};
mine db.forward.zone is:-

Code: Select all

$TTL 1D
@	IN SOA	db.net. admin.db.net. (
					2019112201; serial
					1D	; refresh
					1H	; retry
					1W	; expire
					3H )	; minimum
@		IN	NS	server75.db.net.
@		IN	A	192.168.20.1
server75	IN	A	192.168.20.1
serverora11gr2	IN	A	192.168.20.3
centos6client	IN	A	192.168.20.4
server5		IN	A	192.168.20.5
server6		IN	A	192.168.20.6
mine db.reverse.zone is :-

Code: Select all

$TTL 1D
@	IN SOA	db.net. admin.db.net. (
					2019112201; serial
					1D	; refresh
					1H	; retry
					1W	; expire
					3H )	; minimum
@	IN	NS	server75.db.net.
@	IN	PTR	server75.db.net.
1	IN	PTR	server75.db.net.
3	IN	PTR	serverora11gr2.db.net.
4	IN	PTR	centos6client.db.net.
5	IN	PTR	server5.db.net.
6 	IN 	PTR	server6.db.net.
check zone commands output is :-

Code: Select all

[root@server75 named]# named-checkzone db.net /var/named/db.forward.zone 
zone db.net/IN: loaded serial 2019112201
OK
[root@server75 named]# named-checkzone 20.168.192.ion.addr-arpa /var/named/db.reverse.zone 
zone 20.168.192.ion.addr-arpa/IN: loaded serial 2019112201
OK
check conf command output is :-

Code: Select all

[root@server75 named]# named-checkconf -z /etc/named.conf
zone localhost.localdomain/IN: loaded serial 0
zone localhost/IN: loaded serial 0
zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
zone 0.in-addr.arpa/IN: loaded serial 0
zone db.net/IN: loaded serial 2019112201
zone 20.168.192.in-addr.arpa/IN: loaded serial 2019112201
output of dig commnad is on server side

Code: Select all

[root@server75 named]# dig server5.db.net

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> server5.db.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4840
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

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

;; ANSWER SECTION:
server5.db.net.		86400	IN	A	192.168.20.5

;; AUTHORITY SECTION:
db.net.			86400	IN	NS	server75.db.net.

;; ADDITIONAL SECTION:
server75.db.net.	86400	IN	A	192.168.20.1

;; Query time: 0 msec
;; SERVER: 192.168.20.1#53(192.168.20.1)
;; WHEN: Sat Nov 23 17:56:48 IST 2019
;; MSG SIZE  rcvd: 98
on client side :-

Code: Select all

[root@serverora11gr2 Desktop]# ping 192.168.20.1
PING 192.168.20.4 (192.168.20.4) 56(84) bytes of data.
64 bytes from 192.168.20.4: icmp_seq=1 ttl=64 time=0.810 ms
64 bytes from 192.168.20.4: icmp_seq=2 ttl=64 time=0.844 ms
^C
--- 192.168.20.4 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1221ms
rtt min/avg/max/mdev = 0.810/0.827/0.844/0.017 ms
[root@serverora11gr2 Desktop]# dig  server75.db.net

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> server75.db.net
;; global options: +cmd
;; connection timed out; no servers could be reached
[root@serverora11gr2 Desktop]# dig  -x 192.168.20.1

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6 <<>> -x 192.168.20.1
;; global options: +cmd
;; connection timed out; no servers could be reached
[root@serverora11gr2 Desktop]# 
how to get ping from all clients to server and vice-versa.

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: can ping by ip address but can not ping via hostname

Post by TrevorH » 2019/11/23 13:18:23

Did you open the firewall for the dns ports on the server so that your client can access it?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

rahulvishwa1981
Posts: 5
Joined: 2019/10/26 07:56:47

Re: can ping by ip address but can not ping via hostname

Post by rahulvishwa1981 » 2019/11/24 15:29:20

yes i added them as trusted insterface in server and client.

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: can ping by ip address but can not ping via hostname

Post by jlehtone » 2019/11/25 15:50:45

rahulvishwa1981 wrote:
2019/11/24 15:29:20
yes i added them as trusted insterface in server and client.
I was "wait, CentOS 6 had no firewalld (and 'trusted' is a firewalld zone)" but then noticed:
rahulvishwa1981 wrote:
2019/11/22 15:20:12
i've centos6.10 in VM client and centos7.5 in server
Okay, server can have firewalld.service, but the client is still miscommunication.

You have not described nor shown your actual network layout. Both on server and client:

Code: Select all

ip -4 ad
ip ro
Additionally, on server:

Code: Select all

brctl show
nmcli
firewall-cmd --get-active-zones

rahulvishwa1981
Posts: 5
Joined: 2019/10/26 07:56:47

Re: can ping by ip address but can not ping via hostname

Post by rahulvishwa1981 » 2019/11/26 13:31:01

Accidentally my VMs are crashed. I newly installed centos 7.5 as server and in client. and everything is fine.

Post Reply