0% found this document useful (0 votes)
368 views

Linux Networking Commands New

The document provides information about various Linux networking commands. It lists commands like ifconfig, ip, traceroute, tracepath, ping, netstat, ss, dig, nslookup, route, and describes what each command is used for and provides basic syntax and examples. The commands are used for tasks like displaying and configuring network interfaces, checking connectivity, troubleshooting networks, and looking up domain name system information.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
368 views

Linux Networking Commands New

The document provides information about various Linux networking commands. It lists commands like ifconfig, ip, traceroute, tracepath, ping, netstat, ss, dig, nslookup, route, and describes what each command is used for and provides basic syntax and examples. The commands are used for tasks like displaying and configuring network interfaces, checking connectivity, troubleshooting networks, and looking up domain name system information.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Linux Networking Commands

Every computer is connected to some other computer through a network whether internally
or externally to exchange some information. This network can be small as some computers
connected in your home or office, or can be large or complicated as in large University or
the entire Internet.

Maintaining a system's network is a task of System/Network administrator. Their task


includes network configuration and troubleshooting.

Here is a list of Networking and Troubleshooting commands:

ifconfig Display and manipulate route and network interfaces.

ip It is a replacement of ifconfig command.

traceroute Network troubleshooting utility.

tracepath Similar to traceroute but doesn't require root privileges.

ping To check connectivity between two nodes.

netstat Display connection information.

ss It is a replacement of netstat.

dig Query DNS related information.

nslookup Find DNS related query.

route Shows and manipulate IP routing table.

host Performs DNS lookups.

arp View or add contents of the kernel's ARP table.

iwconfig Used to configure wireless network interface.

hostname To identify a network name.

curl or wget To download a file from internet.


mtr Combines ping and tracepath into a single command.

whois Will tell you about the website's whois.

ifplugstatus Tells whether a cable is plugged in or not.

Linux ifconfig
The command ifconfig stands for interface configurator. This command enables us to
initialize an interface, assign IP address, enable or disable an interface. It display route and
network interface.

You can view IP address, MAC address and MTU (Maximum Transmission Unit) with ifconfig
command.

A newer version of ifconfig is ip command. ifconfig command works for all the versions.

Syntax:

1. ifconfig
Look at the above snapshot, it shows the IP address of all three that is eth, lo and wlan.

Get details of specific interface


To find IP address of all three differently, use command

1. ifconfig eth0
2. ifconfig lo
3. ifconfig wlan0
Assigning IP address and Gateway
You can assign IP address and Gateway to an interface but these settings will be disabled
after system reboot.

Syntax:

1. ifconfig eth0 <address> netmask <address>

Enable or Disable specific interface


To enable specific interface,
1. ifup eth0

To disable specific interface,

1. ifdown eth0

Setting MTU size


By default MTU (Maximum Transmission Unit) size is 1500, you can change size as per your
wish.

1. Ifconfig eth0 mtu xxxx

2. Replace xxxx with size.

Linux ip
This is the newer version of ifconfig command.

Syntax:

1. ip a or ip addr
To get details of specific interface
To find IP address of all three differently, use command

1. ip a show eth0
2. ip a show lo
3. ip a show wlan0

Linux traceroute
The traceroute command is a network troubleshooting utility which helps us to determine
number of hops and packets travelling path required to reach a destination.

Note: If you don't have traceroute utility installed in your system, use the following
command to install it,

1. sudo apt-get install inetutils-traceroute

Now, let's see an example.


Syntax:

1. traceroute <destination>

Exmaple:

1. traceroute javatpoint.com

Linux tracepath
It is similar to traceroute command, but it doesn't require root privileges. By default, it is
installed in Ubuntu but you may have to download traceroute on Ubuntu. It traces the
network path of the specified destination and reports each hop along the path. If you have a
slow network then tracepath will show you where your network is weak.

Syntax:

1. tracepath <destination>

Exmaple:

1. tracepath javatpoint.com
Look at the above snapshot, path to the javatpoint.com is being traced by the tracepath
command.

Linux ping
The ping command stands for (Packet INternet Groper). It checks the connectivity
between two nodes that is whether a server is reachable or not.

ping command keep executing and sends the packet until you interrupt.

To stop from execution press ctrl + c.

ping using DNS


Syntax:

1. ping <destination>

Example:

1. ping javatpoint.com
ping using IP address
You can use IP address also with ping command.

Example:

1. ping 2.2.2.2

ping to limit the packets


To limit the ping packet without using ctrl + c use option c followed by the number of
packet to be send.

Syntax:

1. ping -c <number> <destination>


Example:

1. ping -c 5 javatpoint.com

Look at the above snapshot, packets are limited to 5 without pressing keys.

Linux netstat
The netstat command stands for Network Statistic. It displays information about different
interface statistics including open sockets, routing tables and connection information.

Syntax:

1. netstat

Look at the above snapshot, it is a list of open sockets.


netstat -p
This command displays programs associated with open socket.

netstat -s
It displays detiled statistics for all ports.
netstat -r
This command displays routing table information.

Linux ss
The ss command is a replacement for netstat command. This command gives more
information in comparison to the netstat. It is also faster than netstat as it gets all
information from kernel userspace.

Syntax:

1. ss

Look at the above snapshot, ss command displays all TCP, UDP and socket connections.

Listing listening and connected ports of TCP, UDP


and Unix
If you want to list connected as well as listening ports for TCP, UDP and Unix use -t, -
u and -x respectively with a command.

1. ss -ta
2. ss -ua
3. ss -xa

Listing listening Ports of TCP, UDP and Unix


If you want to list listening ports for TCP, UDP and Unix use -t, -u and -x respectively
with l command.

Syntax:

1. ss -lt
2. ss -lu
3. ss -lx
Linux dig
The dig command
stands for
Domain
Information
Groper.
To find record This
for a particular domain use dig command followed by the domain name.
command is used
for task related to
Syntax:
DNS lookup to
query DNS name
1. dig <domainName>
servers. It mainly
deals with
troubleshoot DNS
related problems.
Look at the above snaphsot, it displays domain name in the answer section.

Linux nslookup
This command is also used to find DNS related query.

Syntax:

1. nslookup <domainName>

Example:

1. nslookup javatpoint.com
Look at the above snapshot, it displays the record information of javatpoint.com

Linux route
The route command displays and manipulate IP routing table for your system.

A router is a device which is basically used to determine the best way to route packets to a
destination.

Syntax:

1. route

Look at the above snapshot, it displays all existing routing table entries on our system.

It shows that if the destination is within the network range of 10.0.0.0 to 10.0.0.255, then
the gateway is *, which is 0.0.0.0. This is a special address which represents an invalid or
non-existent destination.

Packets which are not within this IP range, will be forwarded to default gateway, which
further routes the packet.
Displaying numerical IP address
This command displays output in full numerical form.

Syntax:

1. route -n

Look at the above snapshot, the numerical IP address is displayed.

Adding a default gateway


Packets that are not within the network range are forwarded to the gateway. We can specify
this gateway with the following command,

Syntax:

1. route add default gw <IP address>

Routing cache information


Kernel maintains a routing cache table to route the packets faster. To list this information,
use following command,

Syntax:

1. route -Cn

You might also like