I can ping IP address but can not ping hostname

12,338

In the zone file you have a different IP address for pc2.dtvg.nix: 192.128.2.11 than you were successfully pinging: 192.168.2.11.

You confirmed that the IP addresses in the zone file /var/cache/bind/db.dtvg.nix are wrong so please correct them:

$ORIGIN .
$TTL 604800 ; 1 week
dtvg.nix        IN SOA  dtvg.nix. root.dtvg.nix. (
    140        ; serial
    604800     ; refresh (1 week)
    86400      ; retry (1 day)
    2419200    ; expire (4 weeks)
    604801     ; minimum (1 week 1 second)
)
    NS  gw.dtvg.nix
$ORIGIN dtvg.nix.
$TTL 604800 ; 1 week
gw      A   192.168.2.1
pc1     A   192.168.2.10
pc2     A   192.168.2.11
Share:
12,338

Related videos on Youtube

Keith Reynolds
Author by

Keith Reynolds

Updated on September 18, 2022

Comments

  • Keith Reynolds
    Keith Reynolds over 1 year

    My address:

    user@pc1:~$ ifconfig eth0 |grep "inet " 
            inet addr:192.168.2.10  Bcast:192.168.2.255  Mask:255.255.255.0
    

    I can ping this address

    user@pc1:~$ ping -c 1 192.168.2.11
    PING 192.168.2.11 (192.168.2.11) 56(84) bytes of data.
    64 bytes from 192.168.2.11: icmp_req=1 ttl=64 time=0.686 ms
    
    --- 192.168.2.11 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.686/0.686/0.686/0.000 ms
    

    But pinging its hostname seems to resolve the IP address, but it doesn’t return pings.

    user@pc1:~$ ping -c 1 pc2.dtvg.nix 
    PING pc2.dtvg.nix (192.128.2.11) 56(84) bytes of data.
    
    --- pc2.dtvg.nix ping statistics ---
    1 packets transmitted, 0 received, 100% packet loss, time 0ms
    

    While pinging another hostname on the same network works fine.

    user@pc1 ~$ ping -c1 gw.dtvg.nix 
    PING gw.dtvg.nix (192.168.2.1) 56(84) bytes of data.
    64 bytes from gw.dtvg.nix (192.168.2.1): icmp_req=1 ttl=64 time=0.220 ms
    
    --- gw.dtvg.nix ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 0.220/0.220/0.220/0.000 ms
    

    My /etc/resolve.conf

    user@pc1:~$ cat /etc/resolv.conf 
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 127.0.0.1
    search dtvg.nix
    

    named.conf on my nameserver (gw)

    root@gw:/var/cache/bind# cat /etc/bind/named.conf.local  
    zone "dtvg.nix" {
        type master;
        file "/var/cache/bind/db.dtvg.nix";
        allow-update { key dhcpupdate; };   
    };
    
    zone "2.168.192.in-addr.arpa" {
        type master;
        notify no;
        file "/var/cache/bind/db.2.168.192.in-addr.arpa";
    allow-update { key dhcpupdate; };
    };
    

    Reverse lookup on my nameserver, gw, with unnecessary hosts removed

    root@gw:/var/cache/bind# cat db.2.168.192.in-addr.arpa 
    $ORIGIN .
    $TTL 604800 ; 1 week
    2.168.192.in-addr.arpa   IN SOA dtvg.nix. root.dtvg.nix. (
        140        ; serial
        604800     ; refresh (1 week)
        86400      ; retry (1 day)
        2419200    ; expire (4 weeks)
        604800     ; minimum (1 week)
    )
        NS   gw.dtvg.nix.
    $ORIGIN 2.168.192.in-addr.arpa.
    1           PTR  gw.dtvg.nix.
    $TTL 604800 ; 1 week
    10           PTR    pc1
    11           PTR    pc2
    

    Forward lookup zone file on my nameserver, gw, with unnecessary hosts removed

    root@phoenix:/var/cache/bind# cat db.dtvg.nix 
    $ORIGIN .
    $TTL 604800 ; 1 week
    dtvg.nix        IN SOA  dtvg.nix. root.dtvg.nix. (
        140        ; serial
        604800     ; refresh (1 week)
        86400      ; retry (1 day)
        2419200    ; expire (4 weeks)
        604801     ; minimum (1 week 1 second)
    )
        NS  gw.dtvg.nix
    $ORIGIN dtvg.nix.
    $TTL 604800 ; 1 week
    gw      A   192.168.2.1
    pc1     A   192.128.2.10
    pc2     A   192.128.2.11
    
  • Keith Reynolds
    Keith Reynolds over 10 years
    On my network gw has address 192.168.2.1 pc1 has address 192.168.2.10 and pc2 has address 192.168.2.11 . When i am on pc1 (192.168.2.10) and ping 192.168.2.11, I get ping replies, but when I ping pc2.dtvg.nix it resolves it to IP address 192.168.2.11 but doesn’t return any pings.
  • pabouk - Ukraine stay strong
    pabouk - Ukraine stay strong over 10 years
    @KeithReynolds: In the question the ping makes to resolve the name to a different IP address: 192.128.2.11
  • pabouk - Ukraine stay strong
    pabouk - Ukraine stay strong over 10 years
    @KeithReynolds: pc2.dtvg.nix resolves to 192. 128 .2.11. Do you see the difference from the address of the machine? 192. 168 .2.11
  • Keith Reynolds
    Keith Reynolds over 10 years
    That was it. I over looked the address as you said. I didn't catch it at first but you answered it.
  • pabouk - Ukraine stay strong
    pabouk - Ukraine stay strong over 10 years
    @KeithReynolds: I know this overlooking of a small typo even when you are looking at it again and again :)