Linux (Debian) network configuration

This post covers configuration changes required to set a static IP address on a server / desktop.

First get information about all the interfaces in the system with the command ifconfig -a .

Linux Network ifconfig
ifconfig -a

Network configuration. Assign an address, netmask, gateway and DNS for an ethernet interface in the /etc/network/interfaces files (Debian or Ubuntu).

Edit the file using nano /etc/network/interfaces  and add the following information:

  • address
  • netmask
  • gateway
  • dns-nameservers

The above is for an internal network. If your server is connected directly to the internet you need to use a public address and gateway. If you don’t have these details consult with your server supplier.

Debian Network Configuration
Debian Network Configuration

Apply the changes using the command ifdown etho; ifup eth0 , keep in mind you will lose your SSH connection at this point. Re-connect using the new IP address. Alternatively restart the networking with /etc/init.d/networking restart .

If you get errors connecting, check if a wire is connected with grep “” eth0/*

cd /sys/class/net

grep "" eth0/operstate
grep "" eth1/operstate

grep "" eth0/carrier
grep "" eth1/carrier

When the wire is plugged in:


if the wire is removed


You May Also Like