Introduction to IP Command in Linux
The following article provides you an outline for the various IP Commands in Linux. IP stands for Internet Protocol. It is a numerical value to indicate a device location and its identification in a network.
The ip command is used on Linux operating systems to assign an address to a network interface and/or to configure parameters of the network interface. This command replaces the old great and now outdated command of ifconfig on modern Linux distributions. The ip command is a powerful tool that any Linux system administrator should know about configuring network interfaces. It can be used to upload or down interfaces, assign and remove ARP cache addresses and routes, and much more.
Let us first go through some basic Networking Commands
1. For getting information about host,
- hostname: It will display a machine hostname.
- hostname -i: It will display the IP address for the current machine.
2. For knowing the connection to and fro with the host,
- netstat -g: It will display all the multicast network subscribed by this network.
- netstat -l: will display all listening ports.
- netstat -t: will display all TCP connections.
3. To check connections with hosts and IP address if that is alive of not by sending packets,
Here, we saw 0% packet loss, which means that the connection is established and working properly.
4. To know current network configurations:
ifconfig -a: view all configuration and settings.
5. To discover the hostname and IP address:
6. To know the number of hops and response time to get to a remote system or website:
Now coming to IP (Internet protocols), it is of two types:
- IPV4: Internet Protocol version 4 has a storage capacity of a 32-bit number. The growth of internet and security concerns depleted IPV4 so IPV6 came into the picture.
- IPV6: Internet Protocol version 6 uses a 128-bit number as storage capacity.
So generally, An IP uniquely identifies a host or device on a network. IP ranges are divided into A, B, C, D, E classes which I am surely not going into details as it is mostly theoretical. For example, the dotted-decimal private IP address of C class 192.168.123.132 is (in binary notation) the 32-bit number 110000000101000111101110000100. This number will be hard to make sense of, so divide it into four parts of eight binary digits. The first part of this IP address is used as a network address, the last part as a host address. If you take example 192.168.123.132 and divide it into these two parts you get the following:
192.168.123.0 is a network address. 0.0.0.132 is a host address.
Important IP Command in Linux
Using IP command we can know the device addresses and the network in which our devices reside.
IP OBJECT or IP AbbreviatedForm
So, below are the command list that we can use for the above syntax:
|link||l||Network devise in network|
|address||a||IPv4 or IPv6 address on a device.|
|addrlabel||addrl||Label configuration for protocol address selection.|
|neighbor||n||ARP or NDISC cache entry.|
|route||r||Routing table entry.|
|rule||ru||Rule in routing policy database.|
|mroute||mr||Multicast routing cache|
For example, when we run below command:
IP Address or IP Addr
Additionally, You can use “man ip” which will list down the options available for IP command.
Uses of IP
There are many protocols that use IP addresses. They are:
This protocol is used to connect a remote computer securely. This might require a password and private key file(.PEM).
$ssh -i xyz.pem username@ip-address
Now you can normal Unix commands like ls (to list the directory), cd (to change the directory) and other commands
File transfer protocol is used for establishing a connection with the remote hosts by login and transfer files. You will be prompted to give a password.
$ ftp 220.127.116.11
You can use the “get” command to get files and put command to “put” files on the remote host. FTP is also used to browse the content of directories. Then, you can press the exit if you are finished with transferring of files. Below are lists of useful commands related to FTP.
This protocol is used to remotely control a host and administer them. It is similar to Remote desktop found in window machines. Compared to SSH, TELNET is less secured.
Attempts to open a connection to the remote host my_host.com. If a connection is established, then the host will prompt for a login name and password.
$telnet -l my_username my_host.com 5555
Attempts to open a connection to the remote host my_host.com on port 5555, using the login name my_username. If successful, the host will prompt my_username’s password. Opens a local telnet> prompt, where you may enter any of the commands listed above. For example, entering the below command at the prompt:
telnet> open my_host.com
..will attempt to open a connection to my_host.com, as in our first example. Once authenticated, you may execute commands just like you have done so far, using the Terminal. The only difference is, if you were connected to a remote host, the commands will be executed on the remote machine, and not your local machine. You can exit the telnet connection by entering the command ‘logout’.
Telnet uses at least HOME, SHELL, DISPLAY, and TERM environment variables. Other environment variables may be propagated to the other side via the TELNET ENVIRON option.
- Two hosts must be on the same Ethernet/LAN to Communicate Using IP.
- Each host must have a good connection with the Ethernet. Verify a good connection to the Ethernet using
- various tools like mii-tool.
- Each host should have the same network address, netmask, and broadcast address.
- Each host must have a unique IP address.
- Neither of the hosts must block the other’s IP packets.
Important Usage of IP Command
Here are some important usage of IP command in Linux listed below:
- It is used to find which interfaces are configured on the system and query the status of an IP interface.
- Configure Ethernet, local loop-back and other IP interfaces.
- Modify default and also configure static routing.
- It is used to set up a tunnel over IP and list down ARP cache entry.
- Used to delete, assign and setup routes, subnet, IP address, and other IP info to IP interfaces.
- It is used to display IP and its property.
- Display all status of network and multicast IP addresses information.
- Also, It is used to display neighbor object and manage ARP cache information
- Delete and manage the routing entry.
This is a guide to IP Command in Linux. Here we discuss the syntax, uses, and important IP command in Linux along with its important usage. You may also look at the following articles to learn more –