OpenWrt Forum Archive

Topic: I can ping IP address but can not ping URL. Why???

The content of this topic has been archived on 16 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

In order to test my newly setup WRT160NL, I hook up an intermediate wireless router to my home router for testing purpose.
Here's my setup:

Home wireless router hooked up to DSL broadband. Running wep encryption.
(Intermediate) Asus Wireless router's WAN port connect to one of LAN port on the home router. No encryption.
WRT160NL running Openwrt wireless connect to Asus intermediate router.

My problem is, from WRT160NL, I can ping 74.125.47.99 but I can not ping www.google.com.

root@OpenWrt:/# ping www.google.com
ping: bad address 'www.google.com'

root@OpenWrt:/# ping 74.125.47.99
PING 74.125.47.99 (74.125.47.99): 56 data bytes
64 bytes from 74.125.47.99: seq=0 ttl=50 time=31.082 ms
64 bytes from 74.125.47.99: seq=1 ttl=50 time=24.095 ms
64 bytes from 74.125.47.99: seq=2 ttl=50 time=22.683 ms
64 bytes from 74.125.47.99: seq=3 ttl=50 time=23.143 ms
^C
--- 74.125.47.99 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 22.683/25.250/31.082 ms

root@OpenWrt:/# cat /etc/resolv.conf
nameserver 127.0.0.1

I know that, if I turn off encryption on my home router, and connect WRT160NL to that, then I don't have this problem.

So what happen to the DNS service when I hook up an intermediate router? I tested with my laptop, and the laptop is fine.

I tried google the issue but still can't figure it out.

Thanks, CJ

echo "nameserver xxx.xxx.xxx.xxx" > /etc/resolv.conf

where "xxx.xxx.xxx.xxx" is the ip address of your home router (assuming it is running a DNS server).

If that works and you want to make it permanent remove the symbolic link /etc/resolv.conf (rm /etc/resolv.conf) before issuing the above command.

I'm afraid I'm still confused. When you type the echo "..." > /etc/resolv.conf command, isn't it simply put ... into the resolv.conf file?

Right now my resolv.conf file is:

nameserver 127.0.0.1

cj6666 wrote:

I'm afraid I'm still confused. When you type the echo "..." > /etc/resolv.conf command, isn't it simply put ... into the resolv.conf file?

Right now my resolv.conf file is:

nameserver 127.0.0.1

Do you have dnsmasq running? Editing /etc/resolv.conf is the incorrect way to do it. The way it works is dnsmasq (which is a small lightweight DNS server) that runs on the router. So you set your resolv.conf to go through the local DNS server. The file /tmp/resolv.conf.auto is used by dnsmasq and that is where you put your ISP DNS servers.

cj6666 wrote:

I'm afraid I'm still confused. When you type the echo "..." > /etc/resolv.conf command, isn't it simply put ... into the resolv.conf file?

Right now my resolv.conf file is:

nameserver 127.0.0.1

Did you try what I said to try?

Sorry I didn't have a lot of time to post before. Looking over your original request I may have misunderstood your overall goal. Yes, that command will replace what is in resolv.conf which is the point of what I suggested. This will cause your openwrt to point to your main AP's DNS server to resolve names/IPs. /etc/resolv.conf is just a symbolic link by default to /tmp/resolv.conf which gets created every time you reboot. That's why I said if pointing to your existing DNS server does what you want you can make it permanent by removing the symbolic link and puting the actual file in /etc. There are cases were I set it up that way rather than having a DNS server running on every AP on the local network. Sorry if I am misunderstanding what you are trying to accomplish, maybe a few more details on the big picture?

Are you using the DNS option in /etc/config/network?

#### LAN configuration
config interface lan
    option type     bridge
    option ifname   "eth0.0"
    option proto    static
    option ipaddr   192.168.1.3
    option netmask  255.255.255.0
    option gateway  192.168.1.1
    option dns      192.168.1.1

KillaB, no I didn't use dns option in the /etc/config/network file. I will give it a try.

Curus_mc and Void Man thanks for your replies. dnsmasq is running. Thanks for explaining how the local dns server works. I will try your method as well.

You should also be checking the /tmp/resolv.conf.auto file.

Using the DNS option results in the following:

root@OpenWrt:/# cat /etc/resolv.conf 
nameserver 127.0.0.1

root@OpenWrt:/# cat /tmp/resolv.conf
nameserver 127.0.0.1

root@OpenWrt:/# cat /tmp/resolv.conf.auto 
nameserver 192.168.1.1

(Last edited by KillaB on 16 Jan 2010, 03:26)

KillaB wrote:

You should also be checking the /tmp/resolv.conf.auto file.

Using the DNS option results in the following:

root@OpenWrt:/# cat /etc/resolv.conf 
nameserver 127.0.0.1

root@OpenWrt:/# cat /tmp/resolv.conf
nameserver 127.0.0.1

root@OpenWrt:/# cat /tmp/resolv.conf.auto 
nameserver 192.168.1.1

Ahh, just looked it over a little more closely and I realize that dnsmasq will use /tmp/resolv.conf.auto as a forwarder. I didn't realize that dns option on the interface was there. That should work for him.

Void Main wrote:

I didn't realize that dns option on the interface was there.

It's in Section 1.2.1 of the official documentation:
http://kamikaze.openwrt.org/docs/openwrt.html

It would be nice to see it in the default '/etc/config/network' file, and simply commented out?

In my network interfaces i have nowhere put the dns options. The /etc/resolv.conf has nameserver 127.0.0.1, the /tmp/resolv.conf has search lan, nameserver 127.0.0.1 and /tmp/resolv.conf.auto has nothing. When i tried to edit, or remove and create the resolv.conf.auto, all went ok, until the reboot. After the reboot, all the data in resolv.conf.auto become dissapeared, and the file /tmp/resolv.conf gets back to search lan
  nameserver 127.0.0.1.

bekiaris wrote:

In my network interfaces i have nowhere put the dns options. The /etc/resolv.conf has nameserver 127.0.0.1, the /tmp/resolv.conf has search lan, nameserver 127.0.0.1 and /tmp/resolv.conf.auto has nothing. When i tried to edit, or remove and create the resolv.conf.auto, all went ok, until the reboot. After the reboot, all the data in resolv.conf.auto become dissapeared, and the file /tmp/resolv.conf gets back to search lan
  nameserver 127.0.0.1.

That's because the resolv.conf* files in /tmp are recreated every reboot based on your configuration. If you add that dns option like KillaB suggested (you can even add that dns option in the web interface) it would be listed in your /tmp/resolv.conf.auto when you reboot and cause your local DNS server (on 127.0.0.1) to forward DNS requests to your other DNS server if it can't resolve the host/ip itself.

The discussion might have continued from here.