linux adsl dial automatic configuration script method

  • 2020-06-12 11:42:02
  • OfStack

When using dynamic vps server, I found 1 shell script that has been written for automatic configuration dialing. Share 1 to avoid the trouble of manual configuration. The code is as follows


#! /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 " Please enter the ADSL account :" id
read -p " Please enter the ADSL password :" 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

Related articles: