by Devin Yang
(This article was automatically translated.)

Published - 1 year ago ( Updated - 1 year ago )

Dial pppoe through ISP, sometimes it will disconnect by itself, so we can usually write a simple schedule, let him run once every minute, for example, but things are not that simple, just checking whether ppp0 is connected is not enough , Look at how my bash is written.

Schedule to run every minute, like below

 * * * * * /usr/local/scripts/repppoe.sh


The bash of my repppoe.sh is as follows:

 
#!/bin/bash
/sbin/ifconfig ppp0
if [ $? -gt 0 ];then
    echo "start up ppp0"
    /usr/bin/pon dsl-provider
fi

/sbin/ifconfig ppp1 >/dev/null 2>&1
if [ $? -eq 0 ];then
    #全關
    /usr/bin/poff -a
    sleep 3
    #重撥
    /usr/bin/pon dsl-provider
fi

A little explanation, I usually use simple instructions to check whether the execution is correct,
In the figure below, you can see that when the command is executed successfully, it will return 0, that is to say, there is no problem returning 0, and I don’t need to redial.

There is a one-in-a-million exception, and I encountered it. Maybe ifconfig returned a value other than 0.
This will cause the script to dial a new network ppp1, which is not what I want, just like the following



So in the repppoe.sh above, I detected more ppp1, if for some reason, ppp1 should not appear,
My solution is usually very explosive, just stop him all, and then redial again. 😛

Tags: pppoe

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


ddns,pppoe

Truly free DDNS service

If you need to use DDNS, there are too many fake free DDNS on the Internet, you can really try this one, it is really free and easy to set up. https://www.duckdns.org/DDNS is also called dynamic DNS, which allows our floating IP to obtain a domain name. In this way, we can access our floating IP host through the domain name.

pppoe

How to make pppoe dialup on ubuntu

How to make pppoe dialup on ubuntu