networking.service

The legacy Debian-style network management service, that is tied to the ifupdown system.

Configuration file: /etc/network/interfaces

Refer to NetworkManager.service for the more modern network manager.

Configuring static ip on Debian based Linux distributions (Ubuntu, Kali, Raspberry Pi OS, etc.)

  1. Edit the configuration file: /etc/network/interfaces

General configuration

auto <iface>
iface <iface> inet static
    address xxx.xxx.xx.xxx
    netmask xxx.xxx.xx.xxx
    gateway xxx.xxx.xx.xxx
    broadcast xxx.xxx.xx.xxx

    # Optional: not needed for a basic static ip address configuration
    dns-nameservers <nameserver-address>

Example

Configure network interface eth0 to have the static IP address of 192.168.1.88/24 with the default gateway address of 192.168.1.254, and broadcast address of 192.168.1.255. Optionally, the DNS nameservers can be set too (1.1.1.1 in this case).

auto eth0
iface eth0 inet static
  address 192.168.1.88
  netmask 255.255.255.0
  gateway 192.168.1.254
  broadcast 192.168.1.255
  dns-nameservers 1.1.1.1
  
  1. Restart the networking.service daemon

$ sudo systemctl restart networking.service
  1. Verify the configuration

$ ip address show dev eth0
# or simply:
$ ip a show eth0

Troubleshooting

If the interface fails to display the new configurations, try the following:

  1. Physically unlplug and plug the network adapter back in

  • Take note of the bright green/orange flashing light on the hardware

  • The connection is working if it's present.

  1. Manually restart the interface using the ip or ifconfig tool

  • Bring the interface down and up again

  • The bright green/orange flashing lights should be turned off when the interface is brought down, and will come back up again when the interface is brought up

# ip (preferred method on the latest Linux versions)
$ sudo ip link set <iface> down
$ sudo ip link set <iface> up

# ifconfig 
$ sudo ifconfig <iface> down
$ sudo ifconfig <iface> up

Last updated