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

2020-10-19 10:57:12 浏览数 (2)

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

代码语言:javascript复制
#! /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

以上就是本文的全部内容,希望对大家的学习有所帮助。

0 人点赞