OpenWRT安装PPPoe服务器,当客户端连接或断开时通过ip-down.d/ip-up.d执行ROS命令,ROS需配置使用SSH Key验证。
当系统拨号断开时停止PPPoe:
mkdir /etc/ppp/ip-down.d
cat >/etc/ppp/ip-down.d/pppoe-down.sh << EOF
#!/bin/sh
ssh admin@192.168.1.21 "/interface pppoe-client disable pppoe-out1"
EOF
chmod +x /etc/ppp/ip-down.d/pppoe-down.sh
当连接系统拨号连接时开启PPPoe:
mkdir /etc/ppp/ip-up.d
cat >/etc/ppp/ip-up.d/pppoe-up.sh << EOF
#!/bin/sh
ssh admin@192.168.1.21 "/interface pppoe-client enable pppoe-out1"
EOF
chmod +x /etc/ppp/ip-up.d/pppoe-up.sh
2015.03.17更新:
ros重新拨号只需enable就行,无需先disable:
ssh admin@192.168.1.21 "/interface pppoe-client enable pppoe-out1"
OpenWRT更新到14.07安装的pppoe不执行ip-down.d或up目录下脚本,需添加相应脚本,PPPD连接时会执行此脚本:
cat >/etc/ppp/ip-up << EOF
#!/bin/sh
[ -d /etc/ppp/ip-up.d ] && {
for SCRIPT in /etc/ppp/ip-up.d/*
do
[ -x "$SCRIPT" ] && "$SCRIPT" "$@"
done
}
EOF
chmod +x /etc/ppp/ip-up