How can I bounce a ppp0 connection?

As per the subject, how can I bounce a ppp0 connection? I need to do this in a script so that when the connection gets interrupted it will automatically reconnect. When my dynamic IP address from the ISP changes, as it does most days, the pppo connection can remain active but I can lose internet connectivity, necessitating the bounce. This was never an issue in the past but certainly has been since using the new style network configurations.

What I’ve been using in the past is and what I need to functionally replicate is:

sub bounce_ppoe {
	`ifdown ppp0`;
	sleep 2;
	`ifup ppp0`;
}

I tried using nmcli con down and up but that didn’t work. On “nmcli con down ppp0” I get “Error: ‘ppp0’ is not an active connection. Error: no active connection provided”. On “nmicli con up ppp0” I get “Error: unknown connection ‘ppp0’”.

When the connection is up and I have internet connectivity, “nmcli” lists the NIC interfaces but for the ppp0 is says “ppp0: disconnected”, whereas ifconfig or ip each show it connected, as expected.

The pppo interface was created using nmtui and that works fine for disconnecting and reconnecting but, as fas as I’m aware, it can’t be used in a script, so what can I use?

A reboot will certainly fix the connection but after every reboot I need to check a few things tell rkhunter and tripwire to accept the changes they detect as a consequence of the reboot, because they can’t tell the difference between that and a system compromise. Clearly not an ideal solution.

BTW, this is on the firewall VM for my home network, so having that ppp0 connection up and functioning is pretty important to us.

For background: I’m very new to Rocky, having used Centos7 right up till the start of this month. As a consequence, almost everything I knew about setting up and managing a server is obsolete and the tools and methods I’ve been using for decades no longer work. To make matters worse, I’ve been retired for a number of years and no longer have access to other IT department team members to discuss these things with. As you might imaging, I’m struggling to find and learn the current methods to do many things that were really simple previously. Right now I expecially miss the simplicity of ifcfg-* scripts and associated commands.

For reference, could you show the output of nmcli con and nmcli dev ?

You may need to disconnect the device and reconnect it, rather than down/up the connection.

NAME    UUID                                  TYPE      DEVICE 
pppoe   d0348d83-2c83-4d19-860d-592f188c84c4  pppoe     enp7s0 
LAN     d83cfecb-ac13-3d02-bcd3-36f1f30a7a71  ethernet  enp1s0 
lo      739cf469-45ce-40c1-9998-6e32d9715907  loopback  lo     
enp7s0  6ae6b75e-5f55-3841-af5a-5932b36db907  ethernet  --     
DEVICE  TYPE      STATE                   CONNECTION 
enp7s0  ethernet  connected               pppoe      
enp1s0  ethernet  connected               LAN        
lo      loopback  connected (externally)  lo         
ppp0    ppp       disconnected            --    

Although it says that ppp0 is disconnected it is in fact connected, so nmcli appears to have some issues when dealing with this.

I did have a thought after posting earlier; perhaps I need to bounce enp7s0, the “parent” interface. I tried that and although it gave an error message when going down, it did result in ppp0 reconnacting when I brought enp7s0 back up. Not very clean but perhaps that’s a workable solution.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.