歡迎您光臨本站 註冊首頁

讓adsl連接建立后自動添加網關,並自動把ip同步到3322。

←手機掃碼閱讀     火星人 @ 2014-03-12 , reply:0
  原文作者:xfzhu2008@yahoo.com
文章出處:http://www.linuxeden.com/forum/showthread.php?t=118764

轉載請註明出處:xfzhu2008@yahoo.com
筆者使用rp-pppoe軟體撥號上網,但每次重啟之後都要手動添加網關,
手動同步動態ip到3322,尤為不爽。
本文介紹如何在pppoe連接建立之後自動添加網關。

pppoe連接建立后,系統自動調用/etc/ppp/ip-up腳本。
其參數如下面文件所示,第4個參數是系統獲得的動態ip。
#!/bin/bash
#
# Script which handles the routing issues as necessary for pppd
# Only the link to Newman requires this handling.
#
# When the ppp link comes up, this script is called with the following
# parameters
# $1 the interface name used by pppd (e.g. ppp3)
# $2 the tty device name
# $3 the tty device speed
# $4 the local IP address for the interface
# $5 the remote IP address
# $6 the parameter specified by the 'ipparam' option to pppd
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
route add default gw $4
#下面這一行是使用3322.org的動態域名,如沒有使用,可以不加。
/usr/local/bin/ez-ipupdate -c /usr/local/ezip/qdns.conf


把以上內容存為/etc/ppp/ip-up.local
並chmod 755 /etc/ppp/ip-up.local,使之有執行許可權。
因為ip-up會自動找ip-up.local執行,所以不用修改ip-up文件。

最後執行:
service network restart
ip addr
(多看幾次ip,如果ppp0獲取了ip地址,則用route查看網關是否已經自動添加)
route
祝您成功!


[火星人 ] 讓adsl連接建立后自動添加網關,並自動把ip同步到3322。已經有309次圍觀

http://coctec.com/docs/net/show-post-68415.html