# DSL connection restart for unexperienced user

## lefsha

I've got a DSL connection.

Once a day or even more often it's getting broken.

To get a new connection I start myself this script:

```
/etc/init.d/net.eth0 restart
```

But I can't ask to do it user users working on my comp, cause first they

need root account and second it's not a nice way doing things.

Does anyone know how do I mange it in some better user friendly way?

Any links how to make Linux more user friendly would be very appreciated!

Thanks in advance!

P.S. I'm running KDE under X server. Maybe it would help to answer.

----------

## didymos

Could you post /etc/conf.d/net?

----------

## lefsha

 *didymos wrote:*   

> Could you post /etc/conf.d/net?

 

How it will help?

```
modules=( "!plug" )

config_eth0=( "dhcp")

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

        "dhcpc" # DHCP

)

```

----------

## didymos

 *lefsha wrote:*   

> 
> 
> How it will help?
> 
> 

 

I needed to see how you configure things, so I can do this:

```

modules=( "!plug" )

config_eth0=( "dhcp")

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

        "dhcpc" # DHCP

)

pppd_ppp0=(

    "lcp-echo-interval 15"

    "lcp-echo-failure 3"

    "persist"

    "holdoff 2"

    "mru 1492" 

    "mtu 1492"

    "debug"

    "lock")

```

OK.  It will now send an LCP echo-request frame every 15 seconds to your ISP.  If it fails to respond 3 times in a row, it will assume the connection has died. Normally, that's it:  pppd quits. However, the persist option will instead have it attempt to reconnect until it succeeds.  The holdoff option tells it how long to wait between each attempt: 2 seconds.  The mtu/mru of 1492 is useful since pppoe needs 8 bytes for the packet header.  It'll cut down on packet fragmentation. Leave the debug option in so you can see what happens.  It'll log connection info to the system logs. If it works, you can remove debug from the config.  The lock option makes sure nothing else tries to grab the ppp device.

----------

## lefsha

Hm... Thank you. I will try this.

The only problem I have, that some response fro dhcp server means actually nothing till

I prove this IP for working.

It give me local IP like 196.0.0.X

or say that there is no connection...

But we'll see.

Thanks again.

----------

## didymos

Another option is to give eth0 a static local ip like 192.168.0.2, then create a new symlink:

```

ln -s /etc/init.d/net.lo /etc/init.d/net.ppp0

```

then set /etc/conf.d/net like so:

```

modules=( "!plug" )

config_eth0=( "192.168.0.2/24" )

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

)

pppd_ppp0=(

    "lcp-echo-interval 15"

    "lcp-echo-failure 3"

    "persist"

    "holdoff 2"

    "mru 1492"

    "mtu 1492"

    "debug"

    "lock") 

```

and start the DSL connection with:

```

 /etc/init.d/net.ppp0 start

```

but it could require that the DSL modem/router be configured so it doesn't try handing out DHCP addresses.  However, even if that's not possible, just set this in /etc/conf.d/net:

```

modules=( "!plug" )

config_eth0=( "dhcp" )

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

)

pppd_ppp0=(

    "lcp-echo-interval 15"

    "lcp-echo-failure 3"

    "persist"

    "holdoff 2"

    "mru 1492"

    "mtu 1492"

    "debug"

    "lock") 

```

and keep ppp0 as a separate interface.

----------

## lefsha

 *didymos wrote:*   

> 
> 
> but it could require that the DSL modem/router be configured so it doesn't try handing out DHCP addresses.  However, even if that's not possible, just set this in /etc/conf.d/net:
> 
> 

 

It's everything right, but it doesn't help at all.

The connection is getting broken from IP side.

And if they don't provide me any working IP i can play at my side so long as I want.

So please, could you answer my first question?

How can an ordinary user restart network without getting root permission?

Thank you!

----------

## didymos

What messages appear in the system log when your ISP disconnects you?  Another option is to write your own initscript that checks the interface to see if it's up or tries to ping something.  If it fails, have it restart the net.eth0/net.ppp0 service. Also, what is your current configuration?

----------

## lefsha

 *didymos wrote:*   

> What messages appear in the system log when your ISP disconnects you?  Another option is to write your own initscript that checks the interface to see if it's up or tries to ping something.  If it fails, have it restart the net.eth0/net.ppp0 service. Also, what is your current configuration?

 

Message? I'm getting no message. What you mean by that?

I can see it cause web doesn't work anymore or KWeather shows the question mark.

If I restart network as root sometimes it works, but some times I have to restart DSL modem.

And If I do so, it could happen, that I will get not public IP:

/etc/init.d/net.eth0 restart

```
 * Stopping eth0

 *   Bringing down eth0

 *     Stopping dhcpcd on eth0   [ok ]

 *     Shutting down eth0 ...        [ ok ]

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...             [ ok ]

 *       eth0 received address 192.168.1.64/24

```

Or the IP won't work:

/etc/init.d/net.eth0 restart

```

* Stopping eth0

 *   Bringing down eth0

 *     Stopping dhcpcd on eth0 ... [ ok ]

 *     Shutting down eth0 ...           [ ok ]

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...

Error, eth0: netlink: Network is unreachable  [ok ]

 *       eth0 received address 213.101.248.110/24

```

In the last case only switching off and on DSL modem helps and not always.

I have to repeat this action from 1 to oo times.

So I don't expect that it could be posible to write any script to accomplish that...

That is why my first question and this thread is coming.

I hope now you understand me a little bit more...

Thank you for your answers.

----------

## didymos

Have you tried separating ppp0 into it's own interface, instead of having it directly assign an address to eth0 with DHCP? And when I talk about messages, I mean setting the debug option for pppd and reading the system logs: /var/log/messages.

----------

## petu

 *lefsha wrote:*   

> 
> 
> To get a new connection I start myself this script:
> 
> ```
> ...

 

Quick and dirty solution. Compile a program like this, change owner to root:root and set suid bit. 

```

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <sys/types.h>

#define DEVICE_TO_RESTART "eth0"

int main(int argc, char *argv[])

{

        char **params;

        pid_t pid;

        params = calloc(3, 64);

        params[0] = "";

        params[1] = "eth0";

        pid = fork();

        if(pid == 0)

        {

                printf("main\n");

                params[2] = "down";

                execv("/sbin/ifconfig", params);

                return EXIT_SUCCESS;

        }

        else if(pid > 0)

        {

                printf("child\n");

                if (unlink("/var/run/dhcpcd-eth0.pid") != 0)

                {

                        printf("Error unlinking\n");

                        return -1;

                }

                else {

                        printf("Unlink succesfull\n");

                        params[0] = "dhcpcd";

                        params[2] = "";

                        execv("/sbin/dhcpcd", params);

                        return EXIT_SUCCESS;

                }

        }

        return -1;

}

```

----------

## lefsha

 *didymos wrote:*   

> Have you tried separating ppp0 into it's own interface, instead of having it directly assign an address to eth0 with DHCP? And when I talk about messages, I mean setting the debug option for pppd and reading the system logs: /var/log/messages.

 

Now I'm waiting till it gets broken.

As it happened, I'll put the message here on board.

Yesterday to show you negative response I've manually disconnected from Internet

and spend more then an hour to get it back...

I was so angry about it...

Can't understand why they provide not working IP...

Since today morning I have a working connection and been waiting for any issues...  :Rolling Eyes: 

P.S. Today I was calling to USA and was wondering why nobody takes off.

2 hours later the enlightenment comes to me... - Independence day....

My Congratulation!

----------

## lefsha

 *petu wrote:*   

> 
> 
> Quick and dirty solution. Compile a program like this, change owner to root:root and set suid bit. 
> 
> 

 

Thank you Petu. I will try this if the other way will be not successful.

----------

## lefsha

 *didymos wrote:*   

> Have you tried separating ppp0 into it's own interface, instead of having it directly assign an address to eth0 with DHCP? And when I talk about messages, I mean setting the debug option for pppd and reading the system logs: /var/log/messages.

 

Coming home I've found the internet connection is broken again

and that is the last message I could found in the log file.

```

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: renewing lease of 83.189.16.29

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: received NAK: Lease is invalid.

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: removing default route via 83.189.0.1 metric 0

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: deleting IP address 83.189.16.29/8

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: broadcasting for a lease

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: offered 83.189.5.4 from 10.0.0.138

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: leased 83.189.5.4 for 86400 seconds

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: no renewal time supplied, assuming 43200 seconds

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: no rebind time supplied, assuming 75600 seconds

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: adding IP address 83.189.5.4/8

Jul  5 12:17:09 lefsha dhcpcd[5914]: eth0: adding default route via 83.189.0.1 metric 0

```

The strange thing was, when I tried to reconnect to Internet I've got this message:

```

* Stopping eth0

 *   Bringing down eth0

 *     Stopping dhcpcd on eth0 ...   [ ok ]

 *     Shutting down eth0 ...             [ ok ]

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...                  [ ok ]

 *       eth0 received address 83.189.5.4/8

```

But there was no connection at all.

----------

## didymos

Is your ISP Swipnet?  Also, have you tried this config, with a net.ppp0 symlink?:

```

modules=( "!plug" )

config_eth0=( "192.168.0.2/24" )

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

)

pppd_ppp0=(

    "noauth"

    "peerdns"

    "defaultroute"

    "default-asyncmap"

    "ipcp-accept-remote"

    "ipcp-accept-local"

    "lcp-echo-interval 15"

    "lcp-echo-failure 3"

    "persist"

    "holdoff 2"

    "mru 1492"

    "mtu 1492"

    "debug"

    "lock") 

```

I've added a couple options, just to be on the safe side.  You can actually have the username and password for pppoe in /etc/conf.d/net as well:

```

<snip>

config_ppp0=( "ppp" )

link_ppp0="eth0"

plugins_ppp0=(

        "pppoe" # Required plugin for PPPoE

)

username_ppp0='user'

password_ppp0='password'

<snip>

```

----------

## lefsha

 *didymos wrote:*   

> Is your ISP Swipnet?

 

I know it as Tele2. But you are right. It seems it's the same.

 *didymos wrote:*   

> 
> 
> Also, have you tried this config, with a net.ppp0 symlink?:
> 
> 

 

Not yet. Will do it now. But then I will have no public IP Address...

I will report as soon as I will get broken connection again.

Thanks!

----------

## didymos

You'll still have a public IP, but it will be on the ppp0 interface instead of eth0.  Anything that enters through ppp0 will still go through eth0, and if you go to one of those "What's my ip address" pages (for example: http://www.whatismyipaddress.com/ ), it will still be able to get the address.  It's just easier to make ppp0 separate to debug something like this, and I find it better maintenance-wise.

----------

## lefsha

 *didymos wrote:*   

> You'll still have a public IP, but it will be on the ppp0 interface instead of eth0.  Anything that enters through ppp0 will still go through eth0, and if you go to one of those "What's my ip address" pages (for example: http://www.whatismyipaddress.com/ ), it will still be able to get the address.  It's just easier to make ppp0 separate to debug something like this, and I find it better maintenance-wise.

 

No. Your last version didn't worked at all.

I couldn't get a connection, cause local IP address was granted automatically and there was

no request to ISP.

----------

## didymos

What is in /var/log/messages from when it was trying to connect?

----------

## lefsha

 *didymos wrote:*   

> What is in /var/log/messages from when it was trying to connect?

 

As I told you. It doesn't try to connect cause the IP is granted already... (statical IP).

There is no info about it in /var/log/messages, cause there was no action.

----------

## didymos

Oh,OK, I see. Just to be sure, did you do /etc/init.d/net.ppp0 start? Also, what model of DSL modem is this?

----------

## lefsha

 *didymos wrote:*   

> Oh,OK, I see. Just to be sure, did you do /etc/init.d/net.ppp0 start? Also, what model of DSL modem is this?

 

/var/log/messages

```
Jul  7 01:32:46 lefsha syslog-ng[4887]: syslog-ng starting up; version='2.0.4'

Jul  7 01:33:03 lefsha pppd[6422]: Plugin passwordfd.so loaded.

Jul  7 01:33:03 lefsha pppd[6422]: Plugin rp-pppoe.so loaded.

Jul  7 01:33:03 lefsha pppd[6422]: RP-PPPoE plugin version 3.3 compiled against pppd 2.4.4

Jul  7 01:33:03 lefsha pppd[6423]: pppd 2.4.4 started by root, uid 0

Jul  7 01:33:07 lefsha cron[6744]: (CRON) STARTUP (V5.0)

Jul  7 01:33:07 lefsha cron[6744]: (lefsha) ORPHAN (no passwd entry)

Jul  7 01:33:38 lefsha pppd[6423]: Timeout waiting for PADS packets

Jul  7 01:34:15 lefsha pppd[6423]: Timeout waiting for PADS packets

Jul  7 01:34:52 lefsha pppd[6423]: Timeout waiting for PADS packets

```

rc-update -s

```
net.eth0 |      default

net.lo | boot

net.ppp0 |      default
```

----------

## didymos

What's with the passwordfd.so plugin?  I've never used that before.

----------

## mrness

 *didymos wrote:*   

> What's with the passwordfd.so plugin?  I've never used that before.

 

it is used by baselayout if you set the password_pppX parameter.

----------

