This is a quick guide about how to change the IP addresses in the most popular Linux distros

First, issue any of these commands to find out the version of Linux that you're running:

cat /etc/os-release
  • For Debian and Ubuntu family
  • For CentOS 7
  • For CentOS 8


For Debian and Ubutu family

For Debian we got Ubuntu, Xubuntu, Kubunto, Lubuntu, Mint, etc. Have a look at the file /etc/network/interfaces and you'll notice first the loopback and then your lan on DHCP by default

Version 18.04, Bionic Beaver

This is how the interfaces file looks for DHCP


Needless to say, you already know in Ubuntu there are NO root account, you achieve root privileges but issues "sudo" in front of the vi command to edit it. If you want to set a Static IP, set the interfaces file as below, memorise the entries

auto eth0   #ensures the interface comes on automagically
iface eth0 inet static  #sets interface eth0 to static
#from ubuntu 12.04 the /etc/resolv.conf is not use anymore for DNS, use the below instead

For your changes to take effects, restart the LAN by issuing these commands, though it is recommended to reboot the server (just to ensure that the new settings 'survive' a reboot)

ifdown eth0
ifup eth0

You can also use:

ifconfig eth0 down
ifconfig eth0 up

 If you want to change the mac addresses of your box, create the files "/etc/iftab" and add the mac for your Ethernet with this format: 

eth0 mac 11:22:33:44:55:66

Port binding

For port binding you can do it in Linux using mod 4 (if your switch supports LACP) or mode 6 if it doens't and is using balance-alb (adaptive load balancing). In either case, start by installing the app needed to creating the binding sudo apt install ifeenslave ,then configure the interfaces files as below

auto eth0               #ensure the eth0 comes on automatically
iface eth0 inet manual  #set it to manual
bond-master bond0       #bind the iface to virtual iface called bond0

auto eth1
iface eth1 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
address x.x.x.x
netmask x.x.x.x
gateway x.x.x.x
bond-mode 6       #vmware workstation doesn't support LACP, so we use mode 6
bond-miimon 100   #check the bonding link every 100 milisecods
bond-slaves none  #doesn't claim any slaves, as we already submitted them on inet0 and inet1

 To test the bonding, rung the following command and check that the traffic is split between interfaces

ifconfig | more

Uncomplicated Firewall

ufw (uncomplicated firewall) is disable by default in Ubuntu, but you can enable by doing sudo ufw enable ,the rules for the firewall are stored in /etc/ufw

sudo ufw allow apache  #allows apache in the firewall
sudo ufw allow ssh
sudo ufw status        #check the ports and services that are allowed
sudo ufw disable       #turn it off, if you are nuts and want to use iptables


 While in CentOS the goodies go to /etc/sysconfig, in Debian/Ubuntu the stuff goes to /etc/default. The version of Ubuntu are name with the year of release plus the month, being the month normally either April (04) or October (10), and you should always have a LTS (Long Term Support) release installed, like on my box 18.04, as LTS are supported for 5 years. Funny thing to know as well, every release is also name with an adjective + name of an animal; run cat /etc/os-release to find out yours



For CentOS 7

Issue nmcli device to see the name of the card in use

Edit the ifcfg-ens192 file

vi /etc/sysconfig/network-scripts/ifcfg-ens192

Then add the line NM_CONTROLLED=no so that Network Manager (nmcli) doesn't control that interface, and we can doo all the config using the scripts

For the DNS entries, edit the resolv.conf file

vi /etc/resolv.conf

On a machine with DHCP configure, as default, the file will be similar to this one:



To configure a static IP address, modify the file and add this lines, changing as well the BOOTPROTO entry from "dhcp" to none






For Ubuntu

Visit the file /etc/network/interfaces, if your machine is on DHCP it should look like this:


For CentOS 8

Install the network script package, which for some stupid reason is not installed by default with CentOS 8, just imagine that you need the Internet in order to install these scripts, and the scripts need to be there to configure the Internet, hello CentOS community? wake up! Install the scripts by default, please, so at least we can connect the VM to the Internet the way we want it


dnf install network-scripts


Print Friendly, PDF & Email

Comments powered by CComment