让adsl连接建立后自动添加网关,并自动把ip同步到3322.org - fanqiang...

来源:百度文库 编辑:神马文学网 时间:2024/04/28 14:01:24

让adsl连接建立后自动添加网关,并自动把ip同步到3322.org

作者:xfzhu2008@yahoo.com 来源:Linuxeden (2005-03-21 13:27:25)

笔者使用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
祝您成功!
(http://www.fanqiang.com)

原文链接:http://www.linuxeden.com/forum/showthread.php?t=118764