ip command in Linux with examples

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

ip command in Linux is present in the net-tools which is used for performing several network administration tasks. IP stands for Internet Protocol. This command is used to show or manipulate routing, devices, and tunnels. It is similar to ifconfig command but it is much more powerful with more functions and facilities attached to it. ifconfig is one of the deprecated commands in the net-tools of Linux that has not been maintained for many years. ip command is used to perform several tasks like assigning an address to a network interface or configuring network interface parameters.
It can perform several other tasks like configuring and modifying the default and static routing, setting up tunnel over IP, listing IP addresses and property information, modifying the status of the interface, assigning, deleting and setting up IP addresses and routes.

Syntax:

ip [ OPTIONS ] OBJECT { COMMAND | help }

Options:

  • -address: This option used to show all IP addresses associated on all network devices.
ip address

This will show the information related to all interfaces available on our system, but if we want to view the information of any particular interface, add the options show followed by the name of the particular network interface.

ip address show (interface)

Example:

ip address show ens33
  • -link: It is used_to display link layer information, So it will fetch characteristics of the link layer devices currently available. Any networking device which has a driver loaded can be classified as an available device.
ip link

This link option when used with -s option is usedto show the statistics of the various network interfaces.

ip -s link

So, to get information about a particular network interface, add option show followed by the name of the particular network interface.

ip -s link show (interface)

Example:

ip -s link show ens33
  • -route: So This command helps you to see the route packets your network will take as set in your routing table. The first entry is the default route.
ip route
  • -add: This is usedto assign an IP address to an interface.
ip a add (ip_address) dev interface

Example:

ip a add 192.168.1.50/24 dev ens33
  • -del: This is usedto delete an assigned IP address to an interface.
ip a del (ip_address) dev interface

Example:

ip a del 192.168.1.50/24 dev ens33
  • -up: So This option enables a network interface.
ip link set (interface) up

Example:

ip link set ens33 up
  • -down: This option disables a network interface.
ip link set (interface) down

Example:

ip link set ens33 down
  • -monitor: This command can monitor and displays the state of devices, addresses and routes continuously.
ip monitor
  • -help: This command used as a help to know more about ip command.
ip help
  • -neighbour: This command used to view the MAC address of the devices connected to your system.
ip neighbour
  1. STABLE: This means that the neighbor is valid, but is probably already unreachable, so the kernel will try to check it at the first transmission.
  2. REACHABLE: This means that the neighbor is valid and reachable.
  3. DELAY: This means that a packet has_been sent to the stable neighbor and the kernel is waiting for confirmation.

Modifying ARP(address resolution protocol) entries:

  • Delete an ARP entry:
ip neighbour del (ip_address) dev interface

Example:

ip neighbour del 192.168.0.200 dev ens33
  • Add an ARP entry:
ip neighbour add (ip_address) dev interface

Example:

ip neighbour add 192.168.0.200 dev ens33

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook