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

王朝other·作者佚名  2008-05-21
窄屏简体版  字體: |||超大  

笔者使用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

祝您成功!

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航