# DNS with dhcpcd and WiFi

## ExecutorElassus

I have a laptop running gentoo, and it consistently has issues with WiFi. I can add access points by editing /etc/wpa_supplicant/wpa_supplicant.conf, and it connects fine. Ping with an IP address works fine, but ping with a URL returns nothing at all, and I get errors about "unable to resolve address" issues from the browser.

/etc/resolv.conf has four IP addresses manually entered (two each for OpenDNS and google), plus one added by the router from dhcpcd.

How can I debug why DNS lookups aren't working, and how can I fix it?

Cheers,

EE

----------

## UberLord

libc (the main reader of /etc/resolv.conf) is normally limited to 3 resolvers max - so the last two won't be used.

But you can test DNS by use of the dig command

```
dig www.gentoo.org @192.168.1.1
```

Replace 192.168.1.1 with the DNS server you want to test.

Then, just omit the faulty ones.

----------

## ExecutorElassus

What package provides dig? I don't seem to have it installed. 

Also, the four nameservers I have listed are apparently added to resolv.conf, as deleting them gets overwritten on reboot. Where else might I have them listed?

Cheers,

EE

Update: I take it back. It's not just DNS: commenting out two nameservers, I could resolve addresses. But then I got "destination host unreachable" errors. Even checking with ping, it can't get past the router. So wifi connects to the router, but cant get past it. How can I debug this and fix it?

----------

## bbgermany

Hi,

did you set a default route? Please check with

```

netstat -rn

```

greets, bb

----------

## ExecutorElassus

'netstat -rn' returns:

```
#netstat -rn

Kernel IP routing table

Destination.     Gateway.     Genmask.      Flags.    MSS Window.  irtt. Iface

0.0.0.0.              192.168.1.1 0.0.0.0.          UG.                0 0.            0.  enp4s0

0.0.0.0.               192.168.2.1 0.0.0.0.         UG.                0 0.            0.  wlp3s0

192.168.1.0.      0.0.0.0.        255.255.255.0  U.              0 0.            0.  enp4s0

192.168.2.0.      0.0.0.0.        255.255.255.0. U.              0 0.            0.  wlp3s0

```

Sorry for all the terminal periods. I'm typing on a phone .

See anything here?

Cheers,

EE

----------

## bbgermany

Hi,

there is your issue; two default gateways and no metric. Your system doesnt know which way it should go and where the packages return.

greets, bb

----------

## UberLord

netstat won't show route metric - you need iproute2 for that

```
$ ip r                                                                       

default via 10.73.2.1 dev wlan0 proto static metric 600                                             

10.73.2.0/24 dev wlan0 proto kernel scope link src 10.73.2.30 metric 600                            

169.254.0.0/16 dev wlan0 scope link metric 1000
```

----------

## ExecutorElassus

'ip r' returns:

```
#ip r

default via 192.168.1.1 dev enp4s0 metric 2 linkdown

default via 192.168.2.1 dev wlp3s0 src 192.168.2.52 metric 304

192.168.1.0/24 dev enp4s0 proto kernel scope link src 192.168.1.3 linkdown

192.168.2.0/24 dev wlp3s0 proto kernel scope link src 192.168.2.52 metric 304
```

When I'm at home I use ethernet (enp4s0) but when elsewhere use WiFi (wlp3s0). Is something misconfigured here?

Cheers,

EE

----------

## szatox

Does it start working either after removing this route manually:

```
default via 192.168.1.1 dev enp4s0 metric 2 linkdown 
```

or restarting dhcpcd?

Lower metric has higher priority, so it is possible that you attempt to send packets via a disconnected wired NIC. I never really used dhcpcd in daemon mode, don't know how it handles such cases.

I don't move my box very often, and I've always had more "gui friendly" managers on my laptops.

----------

## ExecutorElassus

I didn't get better results restarting dhcpcd; how do I remove that route manually?

Cheers,

EE

----------

## szatox

```
ip route del default dev enp4s0
```

Did the default route go away from wired NIC after restarting dhcpcd? (And before invoking the above command)

----------

## ExecutorElassus

no, restarting dhcpcd did not remove that route. However, removing it manually did enable me to get a working internet, hurrah! 

Now: how do I ensure that the routes associated with enp4s0 aren't active when I'm not connected to an ethernet cable, so that only the routes associated with wlp3s0 are used?

Thanks for the help! It's almost there!

EE

----------

## nokilli

Not saying this is right, but I've always been manually starting and stopping these things.

```
rc-service net.wlan0 stop
```

```
rc-service net.enp5s0 start
```

And I've never had the issues you're experiencing.  Then too, I don't run a Gnome or KDE which handles this stuff for you.

----------

