3

I am setting up a 3G connection to be monitored by supervisord using wvdial on a headless machine (raspberryPi/raspbian) which I can only access via the 3G connection once it's live. In short, supervisor keeps wvdial running, with wvdial autoreconnect off (I read somewhere that wvdial's not too good at reconnecting automatically).

The connection stays up without any problem, but the default route is not always set, in which case I can't access the box. I can't manually set the route with sudo route add default ppp0, obviously that won't work once live. I could simply run the above in a script, but since it fails if the route already exists I'd need some error handling, and there has to be some clean way of doing it. Any hints on the missing config option?

My config (I think these are the relevant files):

/etc/wvdial.conf:

[Dialer Defaults]
Modem Type = Analog Modem
ISDN = 0
Phone = *99#
Stupid mode=1
Auto Reconnect = off

[Dialer myprovider]
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0
Baud = 115200
Modem = /dev/gsmmodem
Username = xxxx
Password = xxxx

/etc/ppp/peers/wvdial:

noauth
name wvdial
defaultroute
replacedefaultroute

/etc/network/interfaces:

auto eth0
iface eth0 inet static
    address 192.168.2.10
    netmask 255.255.255.0
    gateway 192.168.2.1
    dns-nameservers 8.8.8.8 8.8.4.4
3

You can write your own script that does the routing in /etc/ppp/ip-up.d/

any script in that directory is called from the script /etc/ppp/ip-up

these variables are accessible from ip-up:

# This script is called with the following arguments:
#    Arg  Name                          Example
#    $1   Interface name                ppp0
#    $2   The tty                       ttyS1
#    $3   The link speed                38400
#    $4   Local IP number               12.34.56.78
#    $5   Peer  IP number               12.34.56.99
#    $6   Optional ``ipparam'' value    foo
# These variables are for the use of the scripts run by run-parts
PPP_IFACE="$1"
PPP_TTY="$2"
PPP_SPEED="$3"
PPP_LOCAL="$4"
PPP_REMOTE="$5"
PPP_IPPARAM="$6"
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM

this worked for me was able to add routes and also set the metric.

0

I couldn't find any good solution for this, so I went for a simple cron script that does the following:

#!/bin/bash
route_found=$(/sbin/route -n | /bin/grep -c ^0.0.0.0)
ppp_on=$(/sbin/ifconfig | /bin/grep -c ppp0)
if [ $route_found -eq 0 ] && [ $ppp_on -eq 1 ]
  then /sbin/route add default ppp0
fi

Not great looking, but it does the job! It just checks if a default route is available, and adds one through ppp0 if not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.