# Very unstable internet connection

## George528

Please help me fix my internet issues, it is very unstable.

Often times it just goes down, can't acces any website.

my ipv4 address dissapears and only the ipv6 remains.

This is very frustrationg when i am using ssh, and suddenly my internet goes down, and the connection is lost.

I have to restart the internet every time with "rc-service NetworkManager restart", only then it goes back up.

I can't leave my computer overnight to download a bunch of things because midnight the internet will get down and it will stay idle.

What is the sollution for this?

```
$ ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.0.14  netmask 255.255.255.0  broadcast 192.168.0.255

        inet6 2a00:1858:1018:8514::4  prefixlen 128  scopeid 0x0<global>

        inet6 2a00:1858:1018:8514:9489:38c4:dbb7:c188  prefixlen 64  scopeid 0x0<global>

        inet6 fe80::e4cc:29c2:19db:8137  prefixlen 64  scopeid 0x20<link>

        ether 0c:37:96:12:1f:8c  txqueuelen 1000  (Ethernet)

        RX packets 45070960  bytes 65135691915 (60.6 GiB)

        RX errors 0  dropped 2344  overruns 0  frame 0

        TX packets 17648676  bytes 1270905751 (1.1 GiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 5045062  bytes 57310768119 (53.3 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 5045062  bytes 57310768119 (53.3 GiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.0.17  netmask 255.255.255.0  broadcast 192.168.0.255

        inet6 fe80::8061:9dc6:8944:ce92  prefixlen 64  scopeid 0x20<link>

        inet6 2a00:1858:1018:8514::2  prefixlen 128  scopeid 0x0<global>

        inet6 2a00:1858:1018:8514:f513:2c69:e3a:9da1  prefixlen 64  scopeid 0x0<global>

        ether 74:31:70:c9:dc:62  txqueuelen 1000  (Ethernet)

        RX packets 1027407  bytes 1420600860 (1.3 GiB)

        RX errors 0  dropped 248  overruns 0  frame 0

        TX packets 3200  bytes 690616 (674.4 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

"inet" ip adress dissapears, and i am left only with inet6.

```
$ cat /etc/conf.d/net

# Set the dns_domain_lo variable to the selected domain name

dns_domain_lo="network"

config_eth1="192.168.0.14/24"

routes_eth1="default via 192.168.0.1"

dns_servers_eth1="192.168.0.1 192.168.0.2 2a00:1858:0:1::53"

config_wlan0="dhcp"

#config_wlan0="192.168.0.24/24"

#routes_wlan0="default via 192.168.0.1"

#dns_servers_wlan0="192.168.0.1 192.168.0.2 2a00:1858:0:1::53"

```

also i configured this so my internal ip is stable and it doesn't change, but it still changes.

Please help me.

----------

## steve_v

 *George528 wrote:*   

> NetworkManager
> 
> ...
> 
> /etc/conf.d/net
> ...

 

Of course it did, you're setting a static IP with netiftc and also running NetworkManager. That's a one or the other decision, as explained in the big warning here, and NetworkManager will happily override your changes. 

Personally I don't trust NetworkManager as far as I can throw it, so for debugging purposes I'd suggest disabling it (or removing it completely) and setting up your network via netifrc.

Other than that, I see a bunch of dropped packets on eth0. It may be unrelated, but IME such often indicates driver, hardware, or cabling issues. Is there anything in dmesg regarding the link state on that interface when things go down?

----------

## NeddySeagoon

George528,

You may have at most one tool for managing your network connections, otherwise they fight and neither works properly.

Having two addresses in the same subnet can be an issue too, we need to see your routing tables, both for IPv4 and IPv6.

Some tests.

Stop all your network configuration tools. Then reboot. You should not have any networking at all.

Getting to this stage is important.

Now you can start one or both interfaces by hand and it should be stable. 

You do need to address those dropped packets that steve_v pointed out on eth0 though.

You may need to adjust /etc/rc.conf so that networking works with either/or instead of all.

After you have proved the above, choose at most' one tool to manage your network interfaces.

To help with ssh, log in and start a screen (or tmux) session, then you can detach and reattach as often as I like.

----------

## George528

 *steve_v wrote:*   

>  *George528 wrote:*   NetworkManager
> 
> ...
> 
> /etc/conf.d/net
> ...

 

can you please guide me step by step how to remove networkmanager and use netifrc instead? i removed networkmanager keyword from make.conf and added net.eth0 and eth.wlan0. But i messed up.

Now there is a weird error.

eth0: waiting for carrier 

for 10 sec, and then

ERROR net.eth0 failed to start

also wlan0 failed

also can netifrc connect to wireless internet? will it be hard for me to connect to a new wifi?

----------

## NeddySeagoon

George528,

```
emerge -c networkmanager

emerge --depclean -a
```

The first command removes networkmanager itself if nothing depends on it.

The second command offers to remove all the orphaned packages on your system, including the packages that networkmanager only depended on.

It can remove a lot of packages you wanted to keep too but only you know that. Examine the package list before allowing anything to be removed.

Having said that, you need not remove anything yet. Its good enough to remove entries from the default runlevel, so that the services do not start.

netifrc can start WiFi. You will need to install and configure wpa-supplicant, unless networkmanager  did that for you.

Before you rip things out, remove the services from the default runlevel and test.

Make it work first, rip out the leftovers later.

----------

## steve_v

 *George528 wrote:*   

> can you please guide me step by step

 

Sure.

Step one: Follow Neddy's instructions.

I had more, but the guy is a ninja and it's already been said.  :Razz: 

As for your lack of carrier, the suggestion to try bringing the interface up manually with neither netifrc nor NetworkManager is a good one.

Remove both from your default runlevel, reboot, and bring up the interface by hand with ifconfig and a static IP. Then see if it stays up.

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> You may have at most one tool for managing your network connections, otherwise they fight and neither works properly.
> 
> Having two addresses in the same subnet can be an issue too, we need to see your routing tables, both for IPv4 and IPv6.
> ...

 

how to prevent networkmanager from starting? i couldn't find anywhere

when i run rc-update del NetworkManager, it returns this message "service networkmanager is not in ther runlevel default"

i don't know where is networkmanager, how to disable it?

----------

## steve_v

 *George528 wrote:*   

> when i run rc-update del NetworkManager, it returns this message "service networkmanager is not in ther runlevel default"

 

Is that the actual name of the init script in /etc/init.d/? IIRC it's in CamelCase or something, just to be extra annoying.

Or just delete the symlink in /etc/runlevels/default. That works too.

----------

## NeddySeagoon

George528,

Look in 

```
rc-update show
```

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> Look in 
> 
> ```
> ...

 

```
]$ rc-update show

            acpilight | boot

               binfmt | boot

             bootmisc | boot

              cgroups |                                 sysinit

                 dbus |      default

                devfs |                                 sysinit

                dmesg |                                 sysinit

                 fsck | boot

             hostname | boot

              hwclock | boot

              keymaps | boot

            killprocs |                        shutdown

    kmod-static-nodes |                                 sysinit

                local |      default nonetwork

           localmount | boot

             loopback | boot

              modules | boot

             mount-ro |                        shutdown

                 mtab | boot

               net.lo |      default

             netmount |      default

               procfs | boot

                 root | boot

         save-keymaps | boot

    save-termencoding | boot

            savecache |                        shutdown

                 sshd |      default

        stmpfiles-dev |                                 sysinit

      stmpfiles-setup | boot

                 swap | boot

               sysctl | boot

                sysfs |                                 sysinit

         termencoding | boot

                 udev |                                 sysinit

         udev-trigger |                                 sysinit

              urandom | boot
```

i don't see networkmanager here

----------

## NeddySeagoon

George528,

Its not, nor is net.eth0 nor net.wlan0.

So ... what starts your networking ...

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> Its not, nor is net.eth0 nor net.wlan0.
> 
> So ... what starts your networking ...

 

https://i.imgur.com/7N4P5iA.jpg

this is how it looks at boot

also my interfaces acts very weird:

```
$ ifconfig

eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        ether dc:0e:a1:3e:51:e4  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.0.14  netmask 255.255.255.0  broadcast 192.168.0.255

        inet6 2a00:1858:1018:8514::1  prefixlen 128  scopeid 0x0<global>

        inet6 fe80::c60b:31e8:d8ac:a0c2  prefixlen 64  scopeid 0x20<link>

        inet6 2a00:1858:1018:8514:3628:63db:b622:eb7c  prefixlen 64  scopeid 0x0<global>

        ether 0c:37:96:12:1f:8c  txqueuelen 1000  (Ethernet)

        RX packets 699  bytes 116477 (113.7 KiB)

        RX errors 0  dropped 37  overruns 0  frame 0

        TX packets 92  bytes 13077 (12.7 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.0.17  netmask 255.255.255.0  broadcast 192.168.0.255

        inet6 2a00:1858:1018:8514:f513:2c69:e3a:9da1  prefixlen 64  scopeid 0x0<global>

        inet6 fe80::8061:9dc6:8944:ce92  prefixlen 64  scopeid 0x20<link>

        inet6 2a00:1858:1018:8514::2  prefixlen 128  scopeid 0x0<global>

        ether 74:31:70:c9:dc:62  txqueuelen 1000  (Ethernet)

        RX packets 35  bytes 4041 (3.9 KiB)

        RX errors 0  dropped 1  overruns 0  frame 0

        TX packets 30  bytes 4796 (4.6 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

i don't understand if it appears and dissapears.

Initially i was using usb0 interface (i use usb ethernet adaptor), but now its eth0 for some reason, then sometimes its eth1, and original eth0 appears.

Omg my networking is such a mess.

Please help...

----------

## NeddySeagoon

George528,

What does 

```
ps -Alf | grep -i networkmanager
```

I get 

```
$ ps -Alf | grep -i networkmanager

0 S roy      25825 25818  0  80   0 -  2013 pipe_r 13:26 pts/3    00:00:00 grep --colour=auto -i networkmanager
```

That's the grep itself in the process list. You should get two lines.

The important bits are the numbers 25825 25818.

That's the ProcessID followed by the ParentProcessID.

Next do  

```
$ ps -Alf | grep <ParentProcessID>
```

 to see what started NetworkManager.

Hmm. htop will show you a process tree layout, so that's probably easier.

Anyway the idea is to discover what owns NetworkManager.

Its something in the default runlevel, as that's what Entering runlevel 3 means in your image.

We can rule out sshd and local too.

-- edit --

usb0 is usually for Ethernet 'gadget' interfaces like tethering a mobile phone, where the Ethernet protocol runs over USB without any Ethernet hardware.

USB ethernet adaptors usually get real ethX names.

The kernel allocates ethX names in device discovery order. Its not fixed. 

You can influence device discovery order by making one driver built into the kernel and the other a loadable module. The built in will get eth0, as it will be started before any modules are loaded.

Its also possible to write udev rules to fix the interface names to the device MAC addresses.

If you do that, do not use kernel assigned interface names. Try lan0 and lan1, or whatever is meaningful to you.

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> What does 
> 
> ```
> ...

 

this is what i got.

```
$ ps -Alf | grep -i networkmanager

5 S root      1828     1  0  80   0 - 60624 -      15:25 ?        00:00:01 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid

0 S george    7001  5115  0  80   0 -  1317 -      15:39 pts/3    00:00:00 grep --colour=auto -i networkmanager
```

```

$ ps -Alf | grep 5115

0 S george    5115  2027  0  80   0 -  1665 -      15:39 pts/3    00:00:00 -bash

0 R george   12070  5115  0  80   0 -  1516 -      15:41 pts/3    00:00:00 ps -Alf

0 S george   12071  5115  0  80   0 -  1316 -      15:41 pts/3    00:00:00 grep --colour=auto 5115

$ ps -Alf | grep 1828

5 S root      1828     1  0  80   0 - 60624 -      15:25 ?        00:00:01 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid

0 S george   14716  5115  0  80   0 -  1316 -      15:42 pts/3    00:00:00 grep --colour=auto 1828

```

----------

## NeddySeagoon

George528,

```
5 S root      1828     1  0  80   0 - 60624 -      15:25 ?        00:00:01 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid 
```

Process ID 1 is init, so something started NetworkManager and exited, leaving the somethings children to be owned by init.

Going back to your 

```
$ rc-update show

netmount |      default

    sshd |      default
```

both use the network.

Remove them from the default runlevel and test.

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> ```
> 5 S root      1828     1  0  80   0 - 60624 -      15:25 ?        00:00:01 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid 
> ```
> ...

 

ok i deleted both of them from default runlevel, now i am going to follow the rest of what you have said

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> ```
> 5 S root      1828     1  0  80   0 - 60624 -      15:25 ?        00:00:01 /usr/sbin/NetworkManager --pid-file /run/NetworkManager/NetworkManager.pid 
> ```
> ...

 

My interface is working fine now, but there is one problem.

After i removed netmount from default runlevel, for some reason my .bash_profile doesn't work no more. I had a custom PS1 prompt, but its the default now. I tried adding netmount back but the eth0 would fail to start.

----------

## NeddySeagoon

George528,

Is your ~/.bash_profile file correct?

If so, does 

```
source ~/.bash_profile
```

fix your prompt ?

The netmount service does what it says. Mount the network filesystems listed in /etc/fstab.

If your /home was a network filesystem, the login process would tell you that it couldn't find your /home.

Your ~/.bash_profile would be missing too, along with the rest of your /home directory content.

----------

## George528

 *NeddySeagoon wrote:*   

> George528,
> 
> Is your ~/.bash_profile file correct?
> 
> If so, does 
> ...

 

my bad, looks like i forgot to make .bash_profile automatically source at startup.

Anyways thanks for the help.

----------

