This comprehensive guide will walk you through all of the necessary networking configurations for your Linux machine. If you want to get the most out of Linux and become a power user, you’ll need to understand network configuration.
There are 3 ways to configure Network Administration and Configurations in Linux which are as explained in this blog first by Graphical interface, second by terminal commands third by configuration files.
This your ultimate guide for configuring network And connections in linux. which is somehow a bit confusing but dont worry we have covered all the steps and details. There are 3 Ways to make Configurations:
1. Graphical user interface
The easiest way to set up and configure network in linux is by GUI (Graphical user interface), but it will not be the same in all Linux distributions. So make sure you understand the steps so that you can follow if you have a different distribution.
- 1- search for network settings.
- 2- Change name if you want.
- 3- Go to ip@v4 Change mode to manual, full the blanks by: Ip@ , NetMask , Gateway , DNS
- 4- Save changes.
5- Add a Connextion profile in Linux using the GUI. (Optional):
A connection profile in a linux system offers ability to use different IP adresses for NIC (Network Interface Card). but only one connectin can be used at a time. meaning it’s just allowing you to not go and change your ip address each time you want to connect to another network.
- 1- Go to network settings and add a new profile.
- 2- Give it a name and as you like for example the network name you want to connect to.
- 3- you can change Ip@ to manual and give it a custom Ip@.
2. manage network in Linux by Terminal CLI (ifconfig, nmcli, ip address)
There all many terminal commands that allow to alter and configure network settings in Linux. in this chapter, we explained the best and most common ones.
● ifconfig
ifconfig is an old command short for: “Interface config”
– ifconfig => (Show all inforation about your network intrface card.)
$ ifconfig
sometimes ifconfig utility is not installed by default in all Linux distros that is why you may have o install it. in Ubuntu you can install it like this:
$ sudo apt install net-tools
● nmcli
nmcli stands for “Network management command-line interface”.it is a useful way of configuring networking, especially for remote servers. this command-line tool allows you to deactivate, activate, create, edit, display, and delete network connections as well as show all the network device’s status and details.
– nmcli con show: This command will show all the connexion profiles and the active one in green.)
$ nmcli con show
Show only active profile connexions.
$ nmcli con show --active
To show specific connection profile information.
$ nmcli con show "ExampleConProfile"
Show all the network interface cards of the machine.
$ nmcli device status
To show all information of a Network Interface Card.
nmcli device status "ExampleNetInterface"
Activate a connexion profile.
$ nmcli con up "ExampleConProfile"
Desactivate a connexion profile.
$ nmcli con down "ExampleConProfile"
Add a new connexion profile, but no need for quotation marks just type your values directly.
$ nmcli con add con-name "ConName" ifname "InterfaceName" type "InterfaceType/ethernet..." ip4 "20.0.0.200/24" gw4 "20.0.0.1"
Modify a connexion to add DNS.
$ nmcli con modify con3 ipv4.dns 20.0.0.1
Add/ Append another DNS to a connexion. If you not using “+” it will be modified, Now it’s appended.
nmcli con modify "ConName" +ipv4.dns "8.8.8.8"
Remove a connexion DNS.
nmcli con modify "ConName" -ipv4.dns "8.8.8.8"
activate or desactivate the autoconnection of a con.
nmcli con modify "ConName" connection.autoconnect no/yes
● ip address
ip address is another command to show information about the network. most of the time you can use by default in Linux.
Show all Network interface cards and their IPs.
$ ip address show
Show the connection default gateway.
$ ip route
3. Manage and configure the Network by configuration files
Configuration files allow you to configure networks settings and connections using a text editor. Something to be aware of is that each distribution places these configuration files in a different location. so make sure to read the documentation offered by your Linux OS distribution.
Debian Linux Locating network conf-files :
In most Debian distributions including Debian, Ubuntu, and Kali Linux you will find files to configure network connections.
$ cd /etc/NetworkManager/system-connections
Then to edit a connection profile settings simply edit the file with a text editor like nano or vim. After the file is opened you can simply edit Ip@ NetMask Gateway and so on
sudo nano "ConName"
Fedora Linux Locating network conf-files :
First, go to this path and open a file as a root user using the shorthand command sudo. Then edit and modify your connection profile IPs as you like.
$ cd /etc/sysconfig/network-scripts $ sudo nano/vim ifcfg-"ConName"
After you finish modifications, type these commands after that to restart the network interface using the down/up.
$ sudo nmcli con reload $ nmcli con down "ConName" $ nmcli con up "ConName"