• setting dynamic and fixed ips from bash-terminal – when given care to detail – is working just fine.
  • there are also more or less working network-manager guis.
  • mixing both is not recommended
    • any network-manager gui software should respect the manual settings under /etc/network, but this is not guranteed
      • unfortunately in the past there, there have been inconsistency.
      • (links here and here) what worked in the Debian 6, does not work anymore in 7, hope the this is fixed for good 🙂 (up to Debian 7654)
  • Ubuntu: even when based on Debian comes along with it’s own “netplan” way of managing the network. #argh #standards? #anyone?

either manual or network-manager gui

but not both!!!

  • For laptops and desktops: a network manager gui is probably the best options
  • for servers: manually configuring the network via /etc/network/interfaces is probably the best option.
# check for possible installed network management software
dpkg -l|grep network

network manager gui + temporary fixed ip:

If the user has a desktop running (probably with network manager gui) but want’s a temporary fixed ip, this can be done like this:

su - root
apt install net-tools
# will add an additional virtual ip to eth0, re-do every 3 seconds
while true ; do ifconfig eth0:0 192.168.1.123 up; ip -c a; sleep 3; done;
# more elaborate example
# including connection test to 192.168.$SUBNET.100
SUBNET=0;
while true; do ifconfig enp2s0:4 192.168.$SUBNET.222 up; ip -c addr show; ping -c 3 192.168.$SUBNET.100; sleep 3; clear; done

list all network cards (nic)

to get the actual hardware models of the nic: (creditz)

the lshw tool is not installed per default.

hostnamectl; # tested on
Operating System: Debian GNU/Linux 11 (bullseye)
Kernel: Linux 5.10.0-8-amd64
Architecture: x86-64

su - root
apt udpate
apt install lshw

# now run
lshw -class network -short
H/W path                 Device      Class          Description
===============================================================
/0/100/1c.4/0            enp2s0      network        82574L Gigabit Network Connection
/0/100/1c.5/0            enp3s0      network        82574L Gigabit Network Connection
/0/100/1c.6/0            enp4s0      network        82574L Gigabit Network Connection
/0/100/1c.7/0            enp5s0      network        82574L Gigabit Network Connection
/2                       virbr0      network        Ethernet interface

even more details:

ip -c a s

network config: the gui way

if one plans to use a desktop/Gnome2 Mate one might want to have a network manager widget/gui.

su - root; # become root
apt update; # update the repo
apt-get install network-manager-gnome; # install the network manager tool
# optional:
apt-get install gnome-nettool; # install network debugging tool

network-manager-gnome

nice tool to manage your weird wired and wireless networks

also see: https://dwaves.de/2016/04/15/gnu-linux-debian-install-missing-network-manager-widget-gnome2-network-manager-gnome-and-nettool-alternative-gnome-network-management-utility/ for more screenshots.

or if xfce and other GUI is in use one can also try:

aptitude install wicd; # install wicd network manager tool (optional)

(checkout the documentation about wicd here)

network config: fixed ip: the terminal-bash “headless” server way

permanent fixed ip & additional virtual fixed ips

in order for this to work, it is necessary to remove all network manager tools that might overwrite or somehow interfere with the settings.

lsb_release -d
Description:	Debian GNU/Linux 11 (bullseye)

su - root
apt remove network-manager-gnome
apt remove gnome-nettool

vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# === enp2s0 ===
allow-hotplug enp2s0
# uncomment to use dhcp
# iface enp2s0 inet dhcp

# === enp2s0 ===
# primary fixed ip
auto enp2s0
iface enp2s0 inet static
address 192.168.0.222
netmask 255.255.255.0
gateway 192.168.0.1

# === enp2s0:0 ===
# additional fixed ip on virtual interface (same physical interface, multiple fixed ips)
auto enp2s0:0
iface enp2s0:0 inet static
address 192.168.1.222
netmask 255.255.255.0

DO NOT FORGET THE to restart the network when done with editing:

service networking restart

ALSO: DO NOT FORGET this line:

auto eth0

line, or it might not accept the changes!

it is wise, to monitor the progress on a second terminal, or afterwards (if things fail) with:

journalctl -xe
hostnamectrl; # tested on
debian7

hostnamectl; # also tested on
  Operating System: Debian GNU/Linux 11 (bullseye)
            Kernel: Linux 5.10.0-8-amd64
      Architecture: x86-64

vim /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# === enp2s0 ===
# The primary network interface, inet uplink using dhcp
allow-hotplug enp2s0
iface enp2s0 inet dhcp

# === enp2s0:0 ===
# add another fixed ip address to this interface
# for lan networking (ever changing dhcp address is stress)
auto enp2s0:0
iface enp2s0:0 inet static
address 192.168.4.100
netmask 255.255.255.0
# gateway 192.168.4.1


# debian 11
service networking restart

# alternatively
systemctl restart networking.service

# on older debian 7
/etc/init.d/networking restart
[....] Running /etc/init.d/networking restart is deprecated because it may not r[warnble some interfaces ... (warning).
[ ok ] Reconfiguring network interfaces...done.

# will nicely and colorful display if changes were success :)
ip -c a s

or if that fails:

reboot

in my case it seems this line

auto eth0

and things FAILED gracefully like this:

[warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
[....] Reconfiguring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
done.

more network config examples:

vim /usr/share/doc/ifupdown/examples/network-interfaces.gz; # can be found here

# A "#" character in the very first column makes the rest of the line
# be ignored. Blank lines are ignored. Lines may be indented freely.
# A "" character at the very end of the line indicates the next line
# should be treated as a continuation of the current one.
#
# The "pre-up", "up", "down" and "post-down" options are valid for all
# interfaces, and may be specified multiple times. All other options
# may only be specified once.
#
# See the interfaces(5) manpage for information on what options are
# available.
######################################################################
# The loopback interface isn't really required any longer,
# but can be used if needed.
#
# auto lo
# iface lo inet loopback
# An example ethernet card setup: (broadcast and gateway are optional)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.0.42/24
#     gateway 192.168.0.1
# A more complicated ethernet setup, with a less common netmask, and a downright
# weird broadcast address: (the "up" lines are executed verbatim when the
# interface is brought up, the "down" lines when it's brought down)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.1.42/25
#     up route add -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
#     up route add default gw 192.168.1.200
#     down route del default gw 192.168.1.200
#     down route del -net 192.168.1.128 netmask 255.255.255.128 gw 192.168.1.2
# A more complicated ethernet setup with a single ethernet card with
# two interfaces.
# Note: This happens to work since ifconfig handles it that way, not because
# ifup/down handles the ':' any differently.
# Warning: There is a known bug if you do this, since the state will not
# be properly defined if you try to 'ifdown eth0' when both interfaces
# are up. The ifconfig program will not remove eth0 but it will be
# removed from the interfaces state so you will see it up until you execute:
# 'ifdown eth0:1 ; ifup eth0; ifdown eth0'
# BTW, this is "bug" #193679 (it's not really a bug, it's more of a
# limitation)
#
# auto eth0 eth0:1
# iface eth0 inet static
#     address 192.168.0.100/24
#     gateway 192.168.0.1
# iface eth0:1 inet static
#     address 192.168.0.200
#     netmask 255.255.255.0
# Another way to accomplish this:
#
# auto eth0
# iface eth0 inet static
#     address 192.168.0.100/24
#     gateway 192.168.0.1
# iface eth0 inet static
#     address 192.168.0.200
#     netmask 255.255.255.0
#
# However, when specifying multiple addresses this way, there will be no
# way to add or remove them individually using ifup/ifdown only.
# "pre-up" and "post-down" commands are also available. In addition, the
# exit status of these commands are checked, and if any fail, configuration
# (or deconfiguration) is aborted. So:
#
# auto eth0
# iface eth0 inet dhcp
#     pre-up [ -f /etc/network/local-network-ok ]
#
# will allow you to only have eth0 brought up when the file
# /etc/network/local-network-ok exists.
# Two ethernet interfaces, one connected to a trusted LAN, the other to
# the untrusted Internet. If their MAC addresses get swapped (because an
# updated kernel uses a different order when probing for network cards,
# say), then they don't get brought up at all.
#
# auto eth0 eth1
# iface eth0 inet static
#     address 192.168.42.1
#     netmask 255.255.255.0
#     pre-up /path/to/check-mac-address.sh eth0 11:22:33:44:55:66
#     pre-up /usr/local/sbin/enable-masq
# iface eth1 inet dhcp
#     pre-up /path/to/check-mac-address.sh eth1 AA:BB:CC:DD:EE:FF
#     pre-up /usr/local/sbin/firewall
# Two ethernet interfaces, one connected to a trusted LAN, the other to
# the untrusted Internet, identified by MAC address rather than interface
# name:
#
# auto eth0 eth1
# mapping eth0 eth1
#     script /path/to/get-mac-address.sh
#     map 11:22:33:44:55:66 lan
#     map AA:BB:CC:DD:EE:FF internet
# iface lan inet static
#     address 192.168.42.1
#     netmask 255.255.255.0
#     pre-up /usr/local/sbin/enable-masq $IFACE
# iface internet inet dhcp
#     pre-up /usr/local/sbin/firewall $IFACE
# A PCMCIA interface for a laptop that is used in different locations:
# (note the lack of an "auto" line for any of these)
#
# mapping eth0
#    script /path/to/pcmcia-compat.sh
#    map home,*,*,*                  home
#    map work,*,*,00:11:22:33:44:55  work-wireless
#    map work,*,*,01:12:23:34:45:50  work-static
#
# iface home inet dhcp
# iface work-wireless bootp
# iface work-static static
#     address 10.15.43.23
#     netmask 255.255.255.0
#     gateway 10.15.43.1
#
# Note, this won't work unless you specifically change the file
# /etc/pcmcia/network to look more like:
#
#     if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
#     get_info $DEVICE
#     case "$ACTION" in
#         'start')
#             /sbin/ifup $DEVICE
#             ;;
#         'stop')
#             /sbin/ifdown $DEVICE
#             ;;
#     esac
#     exit 0
# An alternate way of doing the same thing: (in this case identifying
# where the laptop is is done by configuring the interface as various
# options, and seeing if a computer that is known to be on each particular
# network will respond to pings. The various numbers here need to be chosen
# with a great deal of care.)
#
# mapping eth0
#    script /path/to/ping-places.sh
#    map 192.168.42.254/24 192.168.42.1 home
#    map 10.15.43.254/24 10.15.43.1 work-wireless
#    map 10.15.43.23/24 10.15.43.1 work-static
#
# iface home inet dhcp
# iface work-wireless bootp
# iface work-static static
#     address 10.15.43.23
#     netmask 255.255.255.0
#     gateway 10.15.43.1
#
# Note that the ping-places script requires the iproute package installed,
# and the same changes to /etc/pcmcia/network are required for this as for
# the previous example.
# Set up an interface to read all the traffic on the network. This
# configuration can be useful to setup Network Intrusion Detection
# sensors in 'stealth'-type configuration. This prevents the NIDS
# system to be a direct target in a hostile network since they have
# no IP address on the network. Notice, however, that there have been
# known bugs over time in sensors part of NIDS (for example see
# DSA-297 related to Snort) and remote buffer overflows might even be
# triggered by network packet processing.
#
# auto eth0
# iface eth0 inet manual
#       up ifconfig $IFACE 0.0.0.0 up
#       up ip link set $IFACE promisc on
#       down ip link set $IFACE promisc off
#       down ifconfig $IFACE down
# Set up an interface which will not be allocated an IP address by
# ifupdown but will be configured through external programs. This
# can be useful to setup interfaces configured through other programs,
# like, for example, PPPOE scripts.
#
# auto eth0
# iface eth0 inet manual
#       up ifconfig $IFACE 0.0.0.0 up
#       up /usr/local/bin/myconfigscript
#       down ifconfig $IFACE down

Where is the network config file in SUSE12?

vim /etc/sysconfig/network/ifcfg-eth0;

Where is the network config file in CENTOS7? (and probably also in RedHat)

vim /etc/sysconfig/network-scripts/ifcfg-eth0;
admin