(1)免输入密码:
每次pppoeconf都需要输密码,可以修改:
/etc/ppp/peers/dsl-provider文件,在其中增加密码,就可以省略输入密码了:
password 拨号密码
(2)自动拨号
编辑 /etc/network/interfaces
将 pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
这一行移到 auto dsl-provider 上面
# added by pppoeconf
auto eth0
iface eth0 inet manual
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider
auto eth0
iface eth0 inet manual
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider
我的系统有两个无线网卡,一个有线网卡,通过无线网卡与路由器进行连接:
interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
auto dsl-provider
iface dsl-provider inet ppp
#pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
provider dsl-provider
#auto eth0
#iface eth0 inet manual
auto wlan0
iface wlan0 inet manual
auto wlan1
iface wlan1 inet manual
我的一个拨号脚本:
#!/bin/sh
echo "ADSL PPPOE Dial UP Menu"
echo "Please Select:"
echo "\t1\tAuto pppoe config and dial up!"
echo "\t2\tpppoe on"
echo "\t3\tpppoe off"
echo "\t4\tTest connection(ping www.google.com)"
echo "\tq\tquit"
pswd=************************
auto_pppoe()
{
echo "Auto pppoe config and dial up"
echo $pswd | sudo -S pppoeconf
sleep 10
echo $pswd | sudo -S poff dsl-provider
sleep 10
echo $pswd | sudo -S pon dsl-provider
#
sleep 10
#
echo $pswd | sudo -S poff dsl-provider
#
sleep 10
#
echo $pswd | sudo -S pon dsl-provider
}
pppoe_on()
{
echo "pppoe on"
echo $pswd | sudo -S pon dsl-provider
}
pppoe_off()
{
echo "pppoe off"
echo $pswd | sudo -S poff dsl-provider
}
test_connect()
{
echo "test network: ping www.google.com"
ping -c 5 www.google.com > result
if grep -q "64 bytes" result; then
echo "!!!Net work is OK!!!"
exit 0
else
echo "####Net work is NOT ok####"
echo "Try again!"
exit 1
fi
}
read sel
case $sel in
[1]) auto_pppoe;;
[2]) pppoe_on;;
[3]) pppoe_off;;
[4]) test_connect;;
[q]) exit 0;;
*) echo "ONLY accept 1/2/3/4/q"
esac
我的ifconfig -a信息:
chenxibing@chenxibing-desktop:~$ ifconfig -a
eth0 Link encap:以太网 硬件地址 00:24:21:a7:61:3f
inet6 地址: fe80::224:21ff:fea7:613f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:20847 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:17922 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:15785199 (15.7 MB) 发送字节:2506992 (2.5 MB)
中断:28 基本地址:0x6000
lo Link encap:本地环回
inet 地址:127.0.0.1 掩码:255.0.0.0
inet6 地址: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 跃点数:1
接收数据包:88 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:88 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:6176 (6.1 KB) 发送字节:6176 (6.1 KB)
ppp0 Link encap:点对点协议
inet 地址:219.136.81.254 点对点:59.41.222.1 掩码:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 跃点数:1
接收数据包:20802 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:17889 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:3
接收字节:15323200 (15.3 MB) 发送字节:2112090 (2.1 MB)
wlan0 Link encap:以太网 硬件地址 00:16:01:56:9b:3d
BROADCAST MULTICAST MTU:1500 跃点数:1
接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:0 (0.0 B) 发送字节:0 (0.0 B)
wlan1 Link encap:以太网 硬件地址 00:24:01:04:9e:83
BROADCAST MULTICAST MTU:1500 跃点数:1
接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:0 (0.0 B) 发送字节:0 (0.0 B)
我的/etc/rc.local外文件
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
set -x
pswd=131378
auto_pppoe()
{
echo "Auto pppoe config and dial up"
# echo $pswd | sudo -S pppoeconf
# sleep 10
# echo $pswd | sudo -S poff dsl-provider
sleep 3
echo $pswd | sudo -S pon dsl-provider
}
auto_pppoe
exit 0
转载于:https://blog.51cto.com/dongyulong/480954