RPi2 with no internet access after modem reboot

Ask questions about Arch Linux ARM. Please search before making a new topic.

RPi2 with no internet access after modem reboot

Postby Xinayder » Mon Jan 02, 2017 4:04 pm

I have a Raspberry Pi 2 running as a server in my home. Sometimes, my internet access goes away and when it goes back I have to reboot my RPi2 because the ethernet interface has no link to the modem.

In order to fix the issue, I decided to write a script that pings my modem and router, and if one of them is turned off it'll restart the ethernet interface. I setup a timer to run it every 10 minutes, however, it's not working as expected (while the same script runs just fine in a Debian server in my home, using a cronjob). Here's the script:

Code: Select all
#!/bin/bash

MODEM_IP="192.168.1.1"
ROUTER_IP="192.168.0.1"
INTERFACE="eth0"

# Check if we are running the script as root
if [[ $(id -u) -ne 0 ]]; then
  echo "Please execute this script as root."
  exit 1
fi

# Ping router 5 times to check if it's up; then ping modem 5 times to check if it's up.
# If any of these "tests" fail, we restart the interface.
if [[ ! $(ping -c 5 $ROUTER_IP 2>&1 /dev/null | echo $?) -eq 0 ]] && [[ ! $(ping -c 5 $MODEM_IP 2>&1 /dev/null | echo $?) -eq 0 ]]; then
  ifconfig $INTERFACE down
  ifconfig $INTERFACE up
fi


What I'd like to know is why it isn't working. Could it be the timer interval that is too big?
Xinayder
 
Posts: 10
Joined: Mon Jan 02, 2017 3:56 pm

Re: RPi2 with no internet access after modem reboot

Postby graysky » Mon Jan 02, 2017 4:28 pm

How are you controlling the network on the RPi2? Tools like systemd-networkd should do this automatically, no?
graysky
 
Posts: 356
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: RPi2 with no internet access after modem reboot

Postby Xinayder » Mon Jan 02, 2017 4:48 pm

How are you controlling the network on the RPi2? Tools like systemd-networkd should do this automatically, no?

What do you mean with how am I controlling the network? And yeah, it should but it doesn't work, I have to reboot my RPi every time my modem reboots.
Xinayder
 
Posts: 10
Joined: Mon Jan 02, 2017 3:56 pm

Re: RPi2 with no internet access after modem reboot

Postby graysky » Mon Jan 02, 2017 4:59 pm

Post the output of:
Code: Select all
find /etc/systemd/system -mindepth 1 -type d | sed /getty.target/d | xargs ls -gG --color
graysky
 
Posts: 356
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: RPi2 with no internet access after modem reboot

Postby Xinayder » Mon Jan 02, 2017 5:14 pm

Image
Xinayder
 
Posts: 10
Joined: Mon Jan 02, 2017 3:56 pm

Re: RPi2 with no internet access after modem reboot

Postby WarheadsSE » Mon Jan 02, 2017 5:39 pm

Two instances of netctl and systemd-networkd ?
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6730
Joined: Mon Oct 18, 2010 2:12 pm

Re: RPi2 with no internet access after modem reboot

Postby Xinayder » Mon Jan 02, 2017 5:57 pm

Two instances of netctl and systemd-networkd ?

I don't know why I have two of them. I just know that the 'netctl@ethernet\x2dstatic.service' should be handling my static IP address.
Xinayder
 
Posts: 10
Joined: Mon Jan 02, 2017 3:56 pm

Re: RPi2 with no internet access after modem reboot

Postby graysky » Mon Jan 02, 2017 7:55 pm

Xinayder wrote:
Two instances of netctl and systemd-networkd ?

I don't know why I have two of them. I just know that the 'netctl@ethernet\x2dstatic.service' should be handling my static IP address.


...any you don't think that 3 different network daemons all trying to manage 1 device might pose a problem?

Ditch netctl and just use systemd-networkd. See the arch wiki.
graysky
 
Posts: 356
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: RPi2 with no internet access after modem reboot

Postby Xinayder » Mon Jan 02, 2017 9:24 pm

...any you don't think that 3 different network daemons all trying to manage 1 device might pose a problem?

Ditch netctl and just use systemd-networkd. See the arch wiki.


How would I ditch (as in, completely disable it) netctl? I just found out that I am using netctl to assign the IP and systemd-networkd to disable DHCP.
Xinayder
 
Posts: 10
Joined: Mon Jan 02, 2017 3:56 pm

Re: RPi2 with no internet access after modem reboot

Postby graysky » Mon Jan 02, 2017 9:33 pm

Xinayder wrote:How would I ditch (as in, completely disable it) netctl? I just found out that I am using netctl to assign the IP and systemd-networkd to disable DHCP.


graysky wrote:See the arch wiki.
graysky
 
Posts: 356
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Next

Return to User Questions

Who is online

Users browsing this forum: No registered users and 1 guest