I'm here on a Arch Linux box with a working ETH0 (fixed IP) and PPP connection via 3G USB stick (ttyUSB0). After rebooting, ETH0 works fine. Establishing a PPP connection works fine, too. But after using 'poff' to cancel the PPP connection, I don't get a default route again. I know how to set a default route manually, but as the linux boxes will be enrolled in various networks, I have to find an automated process of getting the default route back after using a PPP connection.
ETH0 was configured in /etc/conf.d/net-conf-eth0:
address = 10.0.1.30
netmask = 24
broadcast = 10.0.1.255
gateway = 10.0.1.1
PPP was setup using
pacman -S ppp
... and the following config files:
/etc/ppp/ip-pre-up
#!/bin/sh
/usr/bin/route del default
/etc/ppp/options-mobile
ttyUSB0
921600
lock
crtscts
modem
passive
novj
defaultroute
noipdefault
usepeerdns
noauth
hide-password
persist
holdoff 10
maxfail 0
debug
Routing table before a PPP connection:
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default router.intern 0.0.0.0 UG 0 0 0 eth0
default router.intern 0.0.0.0 UG 1024 0 0 eth0
10.0.1.0 * 255.255.255.0 U 0 0 0 eth0
router.intern * 255.255.255.255 UH 1024 0 0 eth0
Routing table after a successful PPP connection:
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.1.0 * 255.255.255.0 U 0 0 0 eth0
router.intern * 255.255.255.255 UH 1024 0 0 eth0
What am I missing?
To answer my own question: /etc/ppp/ip-down is the clue. (I tried to place a script in /etc/ppp/ip-down.d/, but sometimes it won't get executed. ip-down gets a SIGTERM from pppd too early.) So I modified /etc/ppp/ip-down:
!/bin/sh
#
# This script is run by pppd after the connection has ended.
#
ETH_Gateway=$(/usr/bin/cat /etc/conf.d/net-conf-eth0 | /usr/bin/grep 'gateway' | /usr/bin/grep -oE '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+')
/usr/bin/route del default
/usr/bin/ip route add default via $ETH_Gateway
# Execute all scripts in /etc/ppp/ip-down.d/
for ipdown in /etc/ppp/ip-down.d/*.sh; do
if [ -x $ipdown ]; then
# Parameters: interface-name tty-device speed local-IP-address remote-IP-address ipparam
$ipdown "$@"
fi
done