Fixing Debian Network Management

Post your tutorials and howtos here.
User avatar
Snap
Posts: 1244
Joined: 25 Aug 2013 20:01
Location: Spain

Fixing Debian Network Management

Postby Snap » 14 Aug 2014 09:29

Revised and updated.

By default in Debian the Network Manager does not manage interfaces. Most Debian based distros are tweaked to manage interface connections and some others (like Debian itself) doesn't. Here's where the network management applets and GUIs come to play. This often leads to non working or unstable and/or erratically working connections even in those tweaked distros. I've even seen and experienced this odd behavior in some Ubuntu based distros.

Typical symptoms are non working networks or sporadic disconnections and dropouts. Freezing and stalling during downloads. Networks not responding to the network manager settings introduced by the user, blank network manager settings in the systray, etc...

The cure is easy (big thanks to raymerjacque, the Makulu Linux mantainer, for this tip). 8-)

As usual better backup the two edited files before proceeding, or just comment out the needed lines to easily revert the changes if needed. But I have to say it worked for me every time in different distros.

First edit /etc/network/interfaces and remove (or comment) everything below:

Code: Select all

"iface lo inet loopback"
Then go to /etc/NetworkManager/NetworkManager.conf

Find the lines:

Code: Select all

[ifupdown]
managed=false
and change it to true

Code: Select all

[ifupdown]
managed=true
Then restart the network service

Code: Select all

sudo service network-manager restart
Now you should get a stable and fully working managed network.


All this applies if you need or like to use Network managers. They are intended to make our life easier specially with wireless connections, but they don't succeed every time. The Debian defaults are good. The configuration just works right out of the box. The network managers are the ones that may induce conflicts between the two simultaneous ways of setting up the network connections in our systems.

Personally I'm tired of struggling with the network managers. I just disable or even removed them from my system and went back to the basic default configurations. This involve three files.

/etc/network/interfaces

/etc/resolv.conf

/etc/NetworkManager/NetworkManager.conf


This last one is the responsible of setting the network managed or unmanaged
For managed do this

Code: Select all

[ifupdown]
managed=false
For unmanaged (that's what I want), change the value to true or just comment the line.
Then set your IP in etc/networking/interfaces. For a dynamic IP, the default, this line will do:

Code: Select all

iface eth0 inet dhcp
To set an static IP the use this other line followed but the IP addressings

Code: Select all

iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
Or more complete if you want that

Code: Select all

iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.0.1
If you have two cards just add another one, static or dynamic:

Code: Select all

#Primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
#Secondary network interface
auto eth1
iface eth1 inet dhcp
Then the DNS servers are set into /etc/resolv.conf. By default it's automatically set as something like this during the system installation:

Code: Select all

# Generated by NetworkManager
nameserver 192.168.1.1
This uses you router as a DNS server.

But you can add replace or modify DNS servers at will. Something like this:

Code: Select all

# OpenDNS
nameserver 208.67.222.222
nameserver 208.67.220.220

# Google fallback
nameserver 8.8.8.8
nameserver 8.8.4.4
DNS servers are processed in order, so set first your main ones and the secondary or fallbacks below. You can use as many as you want. But remember, the order matters. Set your trustier ones first.

Don't forget to restart your network service after any configuration change.

Code: Select all

sudo /etc/init.d/networking restart ; start ;  stop
or

Code: Select all

sudo restart networking

Regarding wifi (I never had a computer with wifi, so I have zero experience). I'll better quote Zill here:
Personally, I am not a fan of NetworkManager and so limit its use to my netbook as mentioned above. I generally remove NM and replace it with Wicd, which seems to provide more reliable network management IMHO, including WiFi capability. However, neither NM nor Wicd are necessary for a pure ethernet connection as /etc/network/interfaces performs this function efficiently without any GUI toys!

One advantage of Wicd over NM is that it starts on boot, rather than login, which is very useful if you leave PCs on 24/7 and need connections to stay up continuously for server or backup purposes.
Finally, these are some useful command to check and dealing with our network-manager

To check devices configuration and info

Code: Select all

sudo ifconfig
To release and renew DHCP IP address

Code: Select all

sudo dhclient
To check the host name

Code: Select all

sudo /bin/hostname
To rename the computer just type this

Code: Select all

sudo /bin/hostname newname
and restart the service

Code: Select all

sudo restart networking
This likely means that your installation is broken. -Mr Pixbuf.

Image

User avatar
Snap
Posts: 1244
Joined: 25 Aug 2013 20:01
Location: Spain

Re: Fixing Debian Network Management

Postby Snap » 05 Sep 2014 07:09

Updated! 8-)
This likely means that your installation is broken. -Mr Pixbuf.

Image

User avatar
fleabus
Posts: 1227
Joined: 16 Sep 2013 04:24
Location: Winchester, VA USA

Re: Fixing Debian Network Management

Postby fleabus » 05 Sep 2014 15:17

Probably the reason I was having so much trouble setting up Debian using a static IP before was that I didn't think about removing those GUI tools you mentioned -- And resolv.conf kept getting overwritten. :oops:

I assume one would also remove the desktop-specific ones, for example plasma-nm...?

User avatar
Snap
Posts: 1244
Joined: 25 Aug 2013 20:01
Location: Spain

Re: Fixing Debian Network Management

Postby Snap » 06 Sep 2014 01:22

Probably the reason I was having so much trouble setting up Debian using a static IP before was that I didn't think about removing those GUI tools you mentioned -- And resolv.conf kept getting overwritten. :oops:
No need to :oops: The three more common problems with Linux are: My drivers installed wrong. I have no sound and My network doesn't work. And for very good reasons. I drove crazy with the network so many times due to this duality. Only recently, early this summer, I found out and more or less understood what are the issues and why they might cause conflicts. After many searches and reading the subject all along a year an a half, yesterday I crossed ways with the most clarifying words I've ever found regarding networking in Linux.
Linux systems have connected via ethernet with settings in the /etc/networking/interfaces file since Noah was a boy! The newcomer NetworkManager appeared much later, primarily with the intention of making WiFi connections easier but, by default, the original interfaces file still takes priority with ethernet connections.

Zill.
Wish I found this paragraph a year ago.
I assume one would also remove the desktop-specific ones, for example plasma-nm...?
Mine are removed. If I want to monitor the network activity I use conky or anything else.
This likely means that your installation is broken. -Mr Pixbuf.

Image


Return to “Tutorials”

Who is online

Users browsing this forum: Google [Bot] and 3 guests