What command-line tool can you use in fedora linux to display and change network interface settings?
Nmcli (network manager command-line interface) is a command-line utility used to control the NetworkManager daemon which is used to configure network interfaces. With the nmcli utility, you can display, create, edit, enable and disable network interfaces or connections. It is especially handy for servers and headless systems which do not have a GUI. In
this tutorial, we focus on how you can configure IP networking with the nmcli command in Linux. The nmcli command takes the syntax shown below: $ sudo nmcli [OPTIONS] OBJECT {COMMAND | help } Where Object can be any of the following: Let us now check out how you can configure IP networking
with the nmcli command in Linux Without any command arguments, the nmcli command displays detailed information about all the network interfaces – both active and inactive. Some of the information displayed includes the state of the network connection, hardware type of the network adapter associated with the interface, MAC address, IPv4 and IPv6 addresses and default routes. To get a brief summary of the network interfaces run the command: To list all the active interfaces on your system, execute the command: $ nmcli connection show OR $ nmcli con showThe output displays the name of the connection, UUID, the type of connection (Wired or WiFi) and the device (network interface) Alternatively, you can run the command: $ nmcli connection show --activeSpecify output fields in the outputYou can specify what fields you want to be displayed on the terminal. Valid fields include DEVICE, TYPE, CONNECTION, CONN-UUID, STATE, IP4-CONNECTIVITY, and IP6-CONNECTIVITY. In the example below, we have chosen to display the DEVICE and DEVICE TYPE only. $ nmcli -f DEVICE, TYPE deviceUsing the -p (pretty) option, you can display the output in a more human-readable format where the values and headers are well aligned. $ nmcli -p deviceConfiguring a static IP using the nmcli utilityIn this section, we will demonstrate how you can configure a static IP address with the following values:
Before we assign a static IP, let us check the current IP address of our system which is 192.168.2.104 as indicated. To set the static IP address with the connection name or profile called static-ip, IPv4 address 192.168.2.150, and default gateway 192.168.2.150 we will run the command: $ sudo nmcli con add type ethernet con-name "static-ip" ifname enp0s3 ipv4.addresses 192.168.2.150/24 gw4 192.168.2.1Note: In case you want to disable dhcp ip and configure static ip then run below, $ sudo nmcli con add type ethernet con-name "static-ip" ifname enp0s3 ipv4.method manual ipv4.addresses 192.168.2.150/24 gw4 192.168.2.1Next, we will configure the DNS server as follows. $ sudo nmcli con mod static-ip ipv4.dns "8.8.8.8 8.8.4.4"To activate the connection we will run the command: $ sudo nmcli con up static-ip ifname enp0s3We have simply added another IP address to our network interface enp0s3. To confirm that the IP address was successfully added, we will run the ip command: $ ip addrEnabling / Disabling a network connectionIn this section, we will explore how you can manage the connection by either activating or deactivating them. To disable or deactivate a connection, run the command: You can also simply leave out the ifname enp0s3 parameters. $ sudo nmcli con down id "static-ip"To bring up or enable a connection, run the command: $ sudo nmcli con up id "static-ip" ifname enp0s3Alternatively, you can truncate the command as follows: $ sudo nmcli con up id "static-ip"To check out more on nmcli command options, simply run the command: $ nmcli --helpConclusionThe nmcli utility is a useful tool for adding and managing network connections on Linux systems. It provides easy command-line options to help you configure networking particularly on headless servers. In this guide, we have demonstrated how you can add and manage network connections with the nmcli command in Linux. Also Read: 9 tee Command Examples in Linux What is the Linux command for viewing the IP address of a network interface?Using the ifconfig Command
The system will display all network connections – including connected, disconnected, and virtual. Look for the one labeled UP, BROADCAST, RUNNING, MULTICAST to find your IP address. This lists both IPv4 and IPv6 addresses.
What does ifconfig do in Linux?Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces.
How do I start the network interface from the command line?Open a command prompt as administrator: one way is to enter cmd in the search bar and right-click on the result found, select “Run as administrator”. Type wmic nic get name, index and press Enter. Opposite the name of the network adapter that you need to enable or disable is the index that you need to remember.
How do I change the network interface in Linux?To change your IP address on Linux, use the “ifconfig” command followed by the name of your network interface and the new IP address to be changed on your computer. To assign the subnet mask, you can either add a “netmask” clause followed by the subnet mask or use the CIDR notation directly.
|