The netsh is the popular command in Windows CMD (Command Prompt) that permits you to retrieve network configuration information running on the PC. If you recently shifted to the Linux OS and are looking for the Netsh command there, unfortunately, Linux doesn’t have this command support. Instead, several networking tools are available in Linux to troubleshoot/display the network statistics.
Linux Alternatives for Netsh Command in Linux
Linux is preferred the most regarding security and hardware compatibility to manage networks. As a network administrator, consider the following Linux utilities for network configuration or troubleshooting.
- ifconfig
- ip
- route
- netstat
- systemd (Service Manager)
All the above-mentioned commands come with the net-tools package. Below is the installation of the net-tools package on different Linux distros.
1. For Ubuntu/Debian:
$ sudo apt install net-tools
Installing net-tools package
2. For Fedora/RedHat/CentOS:
$ sudo dnf install net-tools
1. ifconfig
ifconfig is the abbreviation of Interface Configuration, a basic network command in Linux having core functionality to configure/debug/display the network interfaces. Moreover, it also permits the dynamic configuration of network interfaces, assigning IP addresses, and subnetmasks.
Example 1: View All Available Network Interfaces
The network interface is a bridge between the the computer and the public/private network. To view all available network interfaces on the system use the -a flag with ifconfig command.
ifconfig -a
Viewing all available network interfaces
The above output shows all network interfaces. In our case, the network interface “ens33” and “lo” (loopback interface) are listed.
Example 2: Enable/Disable Network Interfaces
To disable a particular network interface, provide the interface name with a “down” option. Correspondingly, to enable the network interface, use the “up” option. Please note that the root privileges will be required for both enabling/disabling processes.
$ sudo ifconfig ens33 down
$ sudo ifconfig ens33 up
Enabling/Disabling Network Interfaces
2. ip
The “ip” stands for Internet Protocol, a built-in command in Linux that shows/manipulates routing, network devices, interfaces, and tunnels. It shares similar functionality as the “ifconfig” command but has some extra advanced features such as configuring policy routing, network namespace, and VLAN (Virtual Lan).
Example 1: Show Network Interfaces
The following IP command with the “addr show” flag displays all available network interfaces on the network.
$ ip addr show
Showing Network Interfaces
In case, if multiple interfaces are running, specify it at the end of the command to retrieve its information:
$ ip addr show <interface name>
Example 2: Get Routing Packets Information
In a network, communication takes place through packets and the routing table holds the routing packets to be sent to the destination. To get routing packet information on the network, this command is considered:
$ ip route
Getting Routing Packets Information
3. route
route is a Linux command that gives the routing table information. The routing table is the set of defined rules for the data packets to be transferred. Moreover, it allows to add, delete, and change the routing entries. You can consider this command if your focus main focus is to manage the IP routing table on the network.
Example 1: Display Routing Table
To obtain the Kernel (manage resources for OS ) IP routing table for the network, simply run the “route” command.
$ route
Disabling Route Table
Example 2: Set/Add Default Gateway IP
Default gateway is used to route the information for a device/network. To set the default gateway on the network, use the “add default” option and specify the IP address. Let’s say, you want to set the default gateway IP “192.168.119. 1“. For this objective, see this command.
$ sudo route add default gw 192.168.119.1
Setting/Adding Default Gateway IP
The default gateway “192.168.119. 1” is set.
4. netstat
The full form of netstat is Network Statistics, a powerful Linux tool for the configuration and troubleshooting the network statistics. It displays the network connections, interface statistics, routing tables, multicast memberships, and masquerade connections.
Example 1: Display All Network Interfaces
To display network all network interfaces using the netstat command, the “-i” is accomplished. For instance, see the following command execution.
$ netstat -i
Displaying all Network Interfaces
Example 2: Display Network Routing Table
As already explained in the “route” command section, the routing table holds destination addresses for the network. To print the routing table with netstat command give the “-r” flag:
$ netstat -r
Displaying Network Routing Table
5. systemd (Service Manager)
In modern Linux distributions, systemd is the default init system service manager. A network service can be managed through this i.e. enabling/disabling a controlled behavior. For instance, the commands are enabling and disabling the NetworkManager services.
$ sudo systemctl enable NetworkManager
$ sudo systemctl disable NetworkManager
Managing Network Service
Conclusion
In conclusion, there’s no Netsh command support available in Linux. However several alternative commands are available that share similar functionalities as netsh command does. You can use the ifocnfig, ip, route, and netstat commands. Additionally, the service manager (systemd) can be used to enable/disable the network services.
Share your thoughts in the comments
Please Login to comment...