# Connection to internet stops working after a while

## iceaway

I have a wireless router which provides internet access through the wireless network. I have several clients on the wireless network, and one of them is acting strangely. After a while (~12-24 hours) the connection to the internet stops working. The internal wireless network is still working, since I can connect to it internally from the other clients. But if I try to access any internet address it tells me that the network is unreachable. If I disable and activate the wireless network (I use NetworkManager) it starts working again. Any ideas what could be causing this?

----------

## Hu

When the client fails, does it lose Internet access or does it lose all network access?  What is the output of ip a ; ip r before and after a failure?

----------

## iceaway

 *Hu wrote:*   

> When the client fails, does it lose Internet access or does it lose all network access?  What is the output of ip a ; ip r before and after a failure?

 

It only loses internet access, I can still access it from my other clients on the local (wireless) network. I didn't seem to have the command 'ip', do you know which package I have to install?

----------

## kurly

 *iceaway wrote:*   

> I didn't seem to have the command 'ip', do you know which package I have to install?

 Should be in sys-apps/iproute2

----------

## iceaway

Thanks! I found it. And here comes the output when the connection is working:

```

# ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN 

    link/ether ee:f1:19:8f:ce:2b brd ff:ff:ff:ff:ff:ff

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 54:04:a6:63:d5:82 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0

4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000

    link/ether 74:2f:68:4a:d5:bf brd ff:ff:ff:ff:ff:ff

    inet 192.168.0.100/24 brd 192.168.0.255 scope global wlan0

# ip r

default via 192.168.0.1 dev wlan0  proto static 

127.0.0.0/8 via 127.0.0.1 dev lo  scope link 

192.168.0.0/24 dev wlan0  proto kernel  scope link  src 192.168.0.100  metric 2 

192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.20  metric 1 

```

and when it isn't working:

```

# ip a       

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN 

    link/ether ee:f1:19:8f:ce:2b brd ff:ff:ff:ff:ff:ff

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

    link/ether 54:04:a6:63:d5:82 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0

4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000

    link/ether 74:2f:68:4a:d5:bf brd ff:ff:ff:ff:ff:ff

    inet 192.168.0.100/24 brd 192.168.0.255 scope global wlan0

# ip r

127.0.0.0/8 via 127.0.0.1 dev lo  scope link 

192.168.0.0/24 dev wlan0  proto kernel  scope link  src 192.168.0.100  metric 304 

192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.20  metric 1 

```

The only thing that seems to differ is the metric for the wlan connection, and that it says "default via 192.168.0.1 dev wlan0  proto static"  for the ip r command. What does that mean?

----------

## Hu

It appears that you are losing your default route, which is why you lose the ability to access resources that are not local to the subnet.  This is most likely a problem with your DHCP client, since it is the one normally responsible for managing both routes and interface addresses.  This theory is supported by your comment that resetting NetworkManager fixes the connectivity problem, since that probably causes it to acquire a new lease and reapply the routing table along the way.

----------

## iceaway

 *Hu wrote:*   

> It appears that you are losing your default route, which is why you lose the ability to access resources that are not local to the subnet.  This is most likely a problem with your DHCP client, since it is the one normally responsible for managing both routes and interface addresses.  This theory is supported by your comment that resetting NetworkManager fixes the connectivity problem, since that probably causes it to acquire a new lease and reapply the routing table along the way.

 

Any ideas what could be causing this? I have been looking through my /var/log/messages for DHCP-related items, but nothing really pops out. I think this is the piece of log from when it stops working:

```

Jun 20 05:30:23 localhost dhcpcd[23226]: wlan0: renewing lease of 192.168.0.100

Jun 20 05:30:23 localhost dhcpcd[23226]: wlan0: NAK: from 192.168.0.1

Jun 20 05:30:23 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed bound -> (null)

Jun 20 05:30:24 localhost dhcpcd[23226]: wlan0: broadcasting for a lease

Jun 20 05:30:24 localhost dhcpcd[23226]: wlan0: offered 192.168.0.100 from 192.168.0.1

Jun 20 05:30:24 localhost dhcpcd[23226]: wlan0: acknowledged 192.168.0.100 from 192.168.0.1

Jun 20 05:30:24 localhost dhcpcd[23226]: wlan0: checking for 192.168.0.100

Jun 20 05:30:29 localhost dhcpcd[23226]: wlan0: leased 192.168.0.100 for 86400 seconds

Jun 20 05:30:29 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed (null) -> bound

```

I looked through the logs for NetworkManger items as well, and this is what happened around 05:30:

```

Jun 20 05:25:37 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  completed -> group handshake

Jun 20 05:25:37 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  group handshake -> completed

Jun 20 05:30:23 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed bound -> (null)

Jun 20 05:30:29 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed (null) -> bound

Jun 20 05:30:29 localhost NetworkManager[2367]: <info>   address 192.168.0.100

Jun 20 05:30:29 localhost NetworkManager[2367]: <info>   prefix 24 (255.255.255.0)

Jun 20 05:30:29 localhost NetworkManager[2367]: <info>   gateway 192.168.0.1

Jun 20 05:30:29 localhost NetworkManager[2367]: <info>   nameserver '192.168.0.1'

Jun 20 05:35:37 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  completed -> group handshake

Jun 20 05:35:37 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  group handshake -> completed

```

I have no idea what that handshake stuff is, but it's doing it every ten minutes or so. When I reconnected manually to get it working again, NetworkManager was doing a lot of other things:

```

Jun 20 06:34:18 localhost NetworkManager[2367]: <info> (wlan0): device state change: 8 -> 3 (reason 39)

Jun 20 06:34:18 localhost NetworkManager[2367]: <info> (wlan0): deactivating device (reason: 39).

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): canceled DHCP transaction, DHCP client pid 23226

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Clearing nscd hosts cache.

Jun 20 06:34:19 localhost NetworkManager[2367]: <warn> (pid 23226) unhandled DHCP event for interface wlan0

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) starting connection 'System (Mondo Gnarp)'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): device state change: 3 -> 4 (reason 0)

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  completed -> disconnected

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): device state change: 4 -> 5 (reason 0)

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0/wireless): access point 'System (Mondo Gnarp)' has security, but secrets are required.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): device state change: 5 -> 6 (reason 0)

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): device state change: 6 -> 4 (reason 0)

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): device state change: 4 -> 5 (reason 0)

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0/wireless): connection 'System (Mondo Gnarp)' has security, and secrets exist.  No new secrets needed.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: added 'ssid' value 'Mondo Gnarp'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: added 'scan_ssid' value '1'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: added 'key_mgmt' value 'WPA-PSK'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: added 'psk' value '<omitted>'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: added 'proto' value 'WPA RSN'

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> Config: set interface ap_scan to 1

Jun 20 06:34:19 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  disconnected -> scanning

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): device state change: 5 -> 3 (reason 0)

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): deactivating device (reason: 0).

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) starting connection 'System (Mondo Gnarp)'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): device state change: 3 -> 4 (reason 0)

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) scheduled...

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) started...

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) scheduled...

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 1 of 5 (Device Prepare) complete.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) starting...

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): device state change: 4 -> 5 (reason 0)

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0/wireless): connection 'System (Mondo Gnarp)' has security, and secrets exist.  No new secrets needed.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: added 'ssid' value 'Mondo Gnarp'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: added 'scan_ssid' value '1'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: added 'key_mgmt' value 'WPA-PSK'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: added 'psk' value '<omitted>'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: added 'proto' value 'WPA RSN'

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 2 of 5 (Device Configure) complete.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  scanning -> disconnected

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Config: set interface ap_scan to 1

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  disconnected -> scanning

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  scanning -> disconnected

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  disconnected -> associating

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  associating -> associated

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  associated -> 4-way handshake

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  4-way handshake -> group handshake

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  group handshake -> completed

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0/wireless) Stage 2 of 5 (Device Configure) successful.  Connected to wireless network 'Mondo Gnarp'.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) scheduled.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) started...

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): device state change: 5 -> 7 (reason 0)

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Beginning DHCPv4 transaction (timeout in 45 seconds)

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> dhcpcd started with pid 28234

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 3 of 5 (IP Configure Start) complete.

Jun 20 06:34:20 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed nbi -> preinit

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> (wlan0): DHCPv4 state changed preinit -> bound

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 4 of 5 (IP4 Configure Get) scheduled...

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 4 of 5 (IP4 Configure Get) started...

Jun 20 06:34:35 localhost NetworkManager[2367]: <info>   address 192.168.0.100

Jun 20 06:34:35 localhost NetworkManager[2367]: <info>   prefix 24 (255.255.255.0)

Jun 20 06:34:35 localhost NetworkManager[2367]: <info>   gateway 192.168.0.1

Jun 20 06:34:35 localhost NetworkManager[2367]: <info>   nameserver '192.168.0.1'

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Scheduling stage 5

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 5 of 5 (IP Configure Commit) scheduled...

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Done scheduling stage 5

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 4 of 5 (IP4 Configure Get) complete.

Jun 20 06:34:35 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 5 of 5 (IP Configure Commit) started...

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> Clearing nscd hosts cache.

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> (wlan0): device state change: 7 -> 8 (reason 0)

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> Clearing nscd hosts cache.

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> Policy set 'System (Mondo Gnarp)' (wlan0) as default for IPv4 routing and DNS.

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> Activation (wlan0) successful, device activated.

Jun 20 06:34:36 localhost NetworkManager[2367]: <info> Activation (wlan0) Stage 5 of 5 (IP Configure Commit) complete.

Jun 20 06:35:37 localhost NetworkManager[2367]: <info> (wlan0): supplicant connection state:  completed -> group handshake

```

The 4th line from the bottom looks quite interesting. Not sure why it does not happens during the DHCP renew at 5:30. Perhaps it's not even supposed to do that if a DHCP is just renewed?

----------

