当前位置:主页 > 服务器 > Linux >

linux adsl 拨号自动配置脚本的方法

时间:2020-11-02 17:16:30 | 栏目:Linux | 点击:

在使用动态vps服务器的时候发现一枚已经写好的自动配置拨号的shell脚本,分享一下,免去手动配置的烦恼,代码如下

#! /bin/sh
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Log=/var/log/pppoe.log
sed -i '/^GATEWAY/d' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/^DNS1/d' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i '/^DNS2/d' /etc/sysconfig/network-scripts/ifcfg-eth0

echo "del ifcfg-eth0 Gateway ...... Success" > $Log
echo "del ifcfg-eth0 DNS1   ...... Success" >> $Log
echo "del ifcfg-eth0 DNS2   ...... Success" >> $Log

read -p "请输入ADSL帐号:" id
read -p "请输入ADSL密码:" ps

sed -i 's/root/'$id'/g' /etc/ppp/chap-secrets
sed -i 's/12345/'$ps'/g' /etc/ppp/chap-secrets

echo "MOdify chap-secrets  ...... Success" >>$Log

sed -i 's/root/'$id'/g' /etc/ppp/pap-secrets
sed -i 's/12345/'$ps'/g' /etc/ppp/pap-secrets

echo "Modify pap-secrets   ......Success" >>$Log

sed -i 's/root/'$id'/g' /etc/sysconfig/network-scripts/ifcfg-ppp0

echo "Modify ifcfg-ppp0   ......Success" >>$Log

echo nameserver 114.114.114.114 >> /etc/resolv.conf
echo nameserver 8.8.8.8 >> /etc/resolv.conf

systemctl restart network.service 

cat $Log
exit

您可能感兴趣的文章:

相关文章