2015-06-01 47 views
-1

我在Arch Linux上使用工作ETH0(固定IP)和通過3G USB棒(ttyUSB0)連接PPP盒。重啓後,ETH0正常工作。建立PPP連接也可以。但是在使用'poff'取消PPP連接後,我再也沒有得到默認路由。我知道如何手動設置一個默認路由,但是由於linux的各種網絡都會被註冊,所以我必須找到一個在使用PPP連接後自動返回默認路由的過程。從PPP連接返回後沒有默認路由

ETH0被配置在/etc/conf.d/net-conf-eth0:使用

pacman -S ppp 

address = 10.0.1.30 
netmask = 24 
broadcast = 10.0.1.255 
gateway = 10.0.1.1 

PPP是設置...和下​​面的配置文件:

的/ etc/PPP/IP的預向上

#!/bin/sh 
/usr/bin/route del default 

的/ etc/ppp/options中移動

ttyUSB0 
921600 
lock 
crtscts 
modem 
passive 
novj 
defaultroute 
noipdefault 
usepeerdns 
noauth 
hide-password 
persist 
holdoff 10 
maxfail 0 
debug 

路由表之前PPP連接:

# 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 

路由表一個成功的PPP連接後:

# 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 

什麼我錯過了嗎?

回答

0

回答我自己的問題:/ etc/ppp/ip-down是線索。 (我試圖在/etc/ppp/ip-down.d/中放置一個腳本,但有時它不會被執行,ip-down從pppd獲得一個SIGTERM過早)。所以我修改了/ etc/ppp/ip簡介:

!/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 "[email protected]" 
    fi 
done