Networking issues - Raspberry pi

charles linquist

New Member
Joined
Oct 27, 2018
Messages
11
Reaction score
1
Credits
0
I'm using a Raspberry pi to connect to a reverse SSH tunnel setup on an Amazon ec2 server. And I'm using a 4G/LTE USB "dongle" to make the connection.

The "dongle" looks like eth0 or eth1 to the Raspberry pi and will usually connect to the carrier during boot. I have added a "SLEEP 16" command in rc.local because the modem boots more slowly than the Raspberry 3 (running STRETCH)..

But I have several problems that I can't seem to figure out:

Problem #1. The Raspberry sometimes hangs at the
"A start job is running on dhcpcd on all interfaces (xx/yy)" (where "xx" and "yy" are times). On some power ups, the system simply hangs at this point forever.

Problem #2. Sometimes the 4G/LTE signal gets blocked and re-appears a few seconds to a few minutes later. I need the Raspberry to automatically reconnect to the Amazon server (over SSH) anytime a connection is possible. The USB "dongle DOES reconnect to the cell network - I can ping servers, etc. Everything works except the SSH connection. I loaded AUTOSSH (rather than just SSH) in an attempt to fix this, but it doesn't work (regardless of the timeouts I select). I have no control or "ping" port available on the Amazon server.
It should be noted that if I manually invoke AUTOSSH after the connection is re-established, everything works as expected.

In another attempt to solve issue #2, I set up a WATCH command that pings GOOGLE (8.8.8.8) every 5 seconds, and if the ping is successful it checks for the presence of a file in RAM and if that file is present, it invokes AUTOSSH and creates the file ( in memory ). If the ping is not successful, the file in memory is deleted. That way, when the system first comes up, it issues AUTOSSH and writes the file. Every 5 seconds thereafter, it pings 8.8.8.8 and if that ping is successful, my script does nothing. If the ping is NOT successful, the file is deleted, so that the next time the ping IS successful, the file won't exist and AUTOSSH will be started again.
It ALMOST works. But it doesn't and I'm stumped.

Note that 'runonce.sh' has the proper permissions (chmod +x runonce.sh)

Can anyone help me solve these two problems? I would greatly appreciate it. I'm including the contents of my files below:

rc.local
################################################
sleep 16 <--- wait for the USB dongle to boot
ifdown -a && ifup -a <-- shut off and turn on ports, this seems to make 1st startup (Prob #1) more reliable
watch -n 5 /home/pi/runonce.sh <--- call 'runonce' every 5 seconds.
exit 0
#########################################################

/home/pi/runonce.sh
#########################################################
ping -c1 8.8.8.8 <-- ping Google server
if [ $? -eq 0 ] ; then <-- good ping
[ -f /dev/shm/keyfile ] || { <-- check for file 'keyfile" in RAM
/home/pi/start-autossh.sh & <-- keyfile not found, so run AUTOSSH - ONE TIME
touch /dev/shm/keyfile <--- create keyfile in RAM (not SD card!)
sudo python /etc/LEDON.py <--- turn LED on to indicate connection
}
else
sudo rm /dev/shm/keyfile <-- ping not good, delete keyfile, autossh will be run next good ping.
sudo pkill /home/pi/start-autossh.sh <-- kill instance of autossh if it is still running
sudo python /etc/LEDOFF.py <-- turn LED off to indicate lost connection
fi
exit 0
#########################################################

Note that these problems do not occur if I connect an Ethernet cable to either the Raspberry's Ethernet port, or to an Ethernet<->USB adapter plugged into a Raspberry's USB port.

If someone could point me to a log file that would tell me what is going on, that would help as well.
 

Members online


Latest posts

Top