What command can you use on a Linux computer to report the IP configuration?
There are a few commands that should always be in your sysadmin toolbox. Get to know these 7 essential networking commands. Show
Posted: June 2, 2021 |%t min read| by Evans Amoany (Sudoer), Tyler Carrigan (Editorial Team, Red Hat) Image Image by Hebi B. from Pixabay This article is the first in a series centered around 'crowd sourced' command recommendations. I asked a group of our core contributors what their favorite Linux commands were, and the feedback was overwhelming. We received 46 individual commands, and many of them were underscored by multiple submissions. This series represents the complete list, broken down by category. I have dubbed these first seven commands "Networking commands that everyone should know." Editors Note: Evans Amoany provided the command information and examples. One of our Sudoers and a talented *nix admin. Shoutout to Evans for doing the heavy lifting here. [ You might also enjoy: Linux networking: 13 uses for netstat ] More about cloud services
ipThe 5 command is one of the basic commands every administrator will need in daily work, from setting up new systems and assigning IPs to troubleshooting existing systems. The 5 command can show address information, manipulate routing, plus display network various devices, interfaces, and tunnels.The syntax is as follows: ip The OBJECT is the most important part of the synopsis, and the following are supported (some omitted for brevity): address - protocol (IPv4 or IPv6) address on a device.
Here are some common use cases for the 5 command.To show the IP addresses assigned to an interface on your server:
To assign an IP to an interface, for example, enps03:
To delete an IP on an interface:
Alter the status of the interface by bringing the interface eth0 online:
Alter the status of the interface by bringing the interface eth0 offline:
Alter the status of the interface by changing the MTU of eth0:
Alter the status of the interface by enabling promiscuous mode for eth0:
Add a default route (for all addresses) via the local gateway 192.168.1.254 that can be reached on device eth0:
Add a route to 192.168.1.0/24 via the gateway at 192.168.1.254:
Add a route to 192.168.1.0/24 that can be reached on device eth0:
Delete the route for 192.168.1.0/24 via the gateway at 192.168.1.254: 0Display the route taken for IP 10.10.1.4: 1ifconfigThe 8 command was/is a staple in many sysadmin's tool belt for configuring and troubleshooting networks. It has since been replaced by the 5 command discussed above. However, if you would like more information on it, check out our previously published article here.mtrMTR (Matt's traceroute) is a program with a command-line interface that serves as a network diagnostic and troubleshooting tool. This command combines the functionality of the 0 and 1 commands. Just like a 1, the 3 command will show the route from a computer to a specified host. 3 provides a lot of statistics about each hop, such as response time and percentage. With the 3 command, you will get more information about the route and be able to see problematic devices along the way. If you see a sudden increase in response time or packet loss, then obviously, there is a bad link somewhere.The syntax of the command is as follows: mtr Let's look at some common use cases. The basic 3 command shows you the statistics, including each hop (hostnames) with time and loss%: 2Show numeric IP addresses (if you use 7, you will get IP addresses (numbers) instead of hostnames): 3Show the numeric IP addresses and hostnames, too: 4Set the number of pings that you want to send: 5Get a report of the 3 command result: 6or: 7Force the use of the TCP instead of the ICMP: 8Force the use of the UDP instead of the ICMP: 9Set the maximum amount of hops: 0Define the packet size: 1Print to CSV output: 2Print to XML output: 3tcpdump
The 9 command is designed for capturing and displaying packets.You can install 9 with the command below: 4Before starting any capture, you need to know which interfaces 9 can use. You will need to use sudo or have root access in this case. 5If you want to capture traffic on eth0, you can initiate that with 2 sample output: 6Capture traffic to and from one hostYou can filter out traffic coming from a specific host. For example, to find traffic coming from and going to 8.8.8.8, use the command: 7For traffic coming from 8.8.8.8, use: 8For outbound traffic going to 8.8.8.8, use: 9Capture traffic to and from a networkYou can also capture traffic to and from a specific network using the command below: 0or: 1You can also filter based on either source or destination. Based on the source (traffic coming from): 2Based on the destination (traffic going to): 3Capture traffic to and from port numbersCapture only DNS port 53 traffic: 4For a specific host, 5To capture only HTTPS traffic, 6To capture all port except port 80 and 25, 7netstatThe 3 tool for printing network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. This utility is part of the net-tool package, as is 8. In the new iproute2 package, the 5 tool is used to achieve the same objectives.If 3 is not found on your system, install it with this command: 8The primary usage of 3 is without any parameters: 9For advanced usage, expand the 3 command with options: 0Or list the options one by one: 1To list all ports and connections regardless of their state or protocol, use: 2List all TCP ports by running: 3List all UDP ports with: 4To return a list of only listening ports for all protocols, use: 5List all listening TCP ports with: 6Return only listening UDP ports by running: 7To list UNIX listening ports, use: 8Display statistics for all ports regardless of the protocol with: 9List statistics for TCP ports only with: 0To view the TCP connections with the PID/Program name listed, use: 1To find a process that is using a particular port number, run: 2nslookupUse the 9 utility to query Internet name servers interactively. Use it to perform DNS queries and receive domain names or IP addresses, or any other specific DNS records.Consider the following common examples. To find the A record of а domain: 3To check the NS records of a domain: 4To find the MX records responsible for the email exchange: 5To find all of the available DNS records of a domain: 6To check the use of a specific DNS server (in this case, query using the specific nameserver ns1.nsexample.com): 7Checking DNS A records to see the IPs of a domain is a common practice, but sometimes you need to verify if an IP address is related to a specific domain. For that purpose, you need a reverse DNS lookup. 8pingPing is a tool that verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) Echo Request messages. The receipt of corresponding Echo Reply messages is displayed, along with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. Simple 0 commands take only one parameter: The hostname or the host IP address that you want to verify. A simple 0 example is just like below: 9You need to stop the 0 command by pressing CTRL+C. Otherwise, it will 0 until you stop it. After every 0 command, it will display a summary report with the following information:
Also, you will see TTL, which stands for Time To Live. Ping uses a numerical TTL value to attempt to reach a given host computer via the route path. This is also known as the hop limit. Normally, when you run a simple 0 command without passing any additional parameters, Linux will 0 that host for an infinite amount of time. If you want to 0 a host ten times, use the following command: 0Use option 8 to view only the 0 statistics summary: 0On systems with multiple interfaces, you can specify the interface for the 0 command to use. If the system has both eth0 and eth1 and I want to 0 using the eth0: 2Or use the address on the interface, assuming the interface as 10.233.201.45 as the IP: 3You can also 0 and specify the IP version as either v4 or v6: 4While pinging a host, you'll find different output from the 0 results, including the following three examples.More Linux resources
Destination Host UnreachableThe possible best reason is there is no route from the local host system and to the destination desired destination host, or a remote router reports that it has no route to the destination host. Request timed outThis result means that no Echo Reply messages were received within the default time of one second or the time that you set while you are pinging that host. This can be due to many different causes; the most common include network congestion, failure of the ARP request, packet filtering/firewall, etc. Unknown host/Ping Request Could Not Find HostMaybe you misspelled the hostname or the host does not exist at all in the network. You must have 0% packet loss for every 0 result with a good latency or lower response time. Depending on which transmission medium (UTP, fiber optics cable, Wi-Fi) you're using, your latency will differ.[ Free cheat sheet: Get a list of Linux utilities and commands for managing servers and networks. ] Looking forwardYou should add these commands and examples into your routines as you configure and troubleshoot your own networks. If you found this type of article helpful, be sure to reach out and let us know. Also, keep an eye out for part two of our community commands list. The next one is 16 general Linux commands that you can't do without.
Check out these related articles on Enable SysadminImage A beginner's guide to network troubleshooting in Linux Every system administrator needs to have at least a basic understanding of network troubleshooting. And the first rule of network troubleshooting to remember is, "Packets don't lie." Posted: September 24, 2019 Author: Anthony Critelli (Sudoer) Image My go-to Linux network troubleshooting commands Every sysadmin needs a good troubleshooting strategy, and you can't fix a problem if you cannot identify it. These are my favorite commands to quickly filter through the possibilities of a given problem. Posted: November 29, 2019 Author: Tyler Carrigan (Editorial Team, Red Hat) Image Packet sniffer basics for network troubleshooting Capturing packets with a free tool like tcpdump is an essential skill that you need to acquire as a sysadmin. Anthony Critelli shows you the ropes. Posted: November 19, 2019 Author: Anthony Critelli (Sudoer) Topics: Linux Linux administration Networking Command line utilities Evans AmoanyI work as Unix/Linux Administrator with a passion for high availability systems and clusters. I am a student of performance and optimization of systems and DevOps. I have passion for anything IT related and most importantly automation, high availability, and security. More about me Tyler CarriganTyler is the Sr. Community Manager at Enable Sysadmin, a submarine veteran, and an all-round tech enthusiast! He was first introduced to Red Hat in 2012 by way of a Red Hat Enterprise Linux-based combat system inside the USS Georgia Missile Control Center. More about me Red Hat Summit 2022: On DemandGet the latest on Ansible, Red Hat Enterprise Linux, OpenShift, and more from our virtual event on demand. Register for free Related ContentImage How to schedule jobs using the Linux 'cron' utility Scheduling tasks to run automatically at specific times is essential knowledge for any sysadmin. Posted: December 15, 2022 Author: Alexon Oliveira (Sudoer, Red Hat) Image Learn how Unix influenced Linux, understand Ansible lists and dictionaries, and more tips for sysadmin Which command will display the configured IP address?Using the ipconfig Command
The ipconfig command displays the basic IP addressing information for each network interface on the Windows system. This information includes both the IP address and subnet mask.
Which of the following commands will display the IP address on a Linux system?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.
Which command can we use to get the IP address of a Linux computer quizlet?In Linux, the ipconfig command is used to examine current IP address settings.
What is the Linux macOS equivalent of ipconfig?ifconfig is a command in Unix-like operating systems like Linux, FreeBSD, OpenBSD, macOS for Ethernet network interface configuration. In macOS, the ifconfig command functions as a wrapper to the IPConfiguration agent, and can control the BootP and DHCP clients from the command-line.
|