There are several commands which can help to diagnose the computer networking in Linux.
- ifconfig Command
Interface configuration(ifconfig) is a command-line interface tool used for configuring, controlling and querying TCP/IP network interface parameters.It is used to initialize an interface, set the IP address and netmask of a network interface and enabling or disabling an interface on demand.
This command is mainly used to know the IP address and MAC address assigned to an interface.
-->ifconfig command with no arguments will display will display all network interfaces currently in operation.
$ifconfig -a
It will display all available details of the system irrespective of status.It doesn't bother whether the interface is inactive or active.
$ifconfig eth0
It will show the configuration of a specific interface i.e. it will display the configuration of eth0 only.
We can change the status of a specific network interface from active to inactive, or vice-versa.Only a superuser can enable or disable an interface.So we need to be logged in as root or prefix the command with sudo.
To disable an active network interface, enter ifconfig with the interface name followed by the down keyword.
$ sudo ifconfig eth0 down
Similarly to enable an inactive network interface, enter ifconfig with the interface name followed by the up keyword.
$sudo ifconfig eth0 up
It can also be used to assign IP address and Gateway to an interface.To assign a static IP address and the network mask to an interface, specify the interface name, IP address, and network mask.
This command also requires superuser privileges.
$sudo ifconfig eth0 192.168.10.12 netmask 255.255.255.0
- PING Command
The PING command is used to test the connection and latency between two network connections(i.e. nodes).These connections can be either in a local area network(LAN) or a wide area network(WAN).PING uses ICMP(Internet Control Message Protocol).It sends ICMP ECHO_REQUEST packets to network hosts.
$ping 192.168.10.1
In Linux ping command keep executing until we forcefully stop by interrupting it with the Ctrl+C keystroke.Ping with -c option exit after N number of requests.
$ping -c 7 www.google.com
- TRACEROUTE Command
The Internet is a large and complex aggregation of network hardware connected together by gateways.
It is a network troubleshooting utility which shows the path to the destination and the number of hops taken to reach the destination.It utilizes the IP protocol "time to live" field and attempts to elicit ICMP TIME_EXCEEDED response from each gateway along the path to some host.
$traceroute 192.168.10.12
- NETSTAT Command
It is a command line TCP/IP networking utility for monitoring network connections both incoming and outgoing.It displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc.
$netstat -a
It lists out all the current connections.
To list out only tcp connections use the t option
$netstat -at
To list out only udp connections use u option
$netstat -au
To list out all listening connections
$netstat -l
To display routing table information
$netstat -r
To list out all listening connections
$netstat -l
To display routing table information
$netstat -r
- ARP Command
ARP stands for Address Resolution Protocol.It is one of the major protocol in TCP/IP suit. This protocol is used to match IP addresses(32-bit Ethernet address) to MAC addresses(48-bit Hardware address).
To view the ARP cache table
$arp -a
To delete manually an entry from ARP cache
$arp -d ip-address
To view the ARP cache table
$arp -a
To delete manually an entry from ARP cache
$arp -d ip-address
- NSLOOKUP Command
It is a command-line tool for querying the Domain Name System(DNS) to obtain domain name or IP address mapping or for other specific DNS records.
$nslookup www.fb.com
$nslookup www.fb.com
- DIG Command
We can use dig command to query DNS lookup related task.It is used to query information like A Record, CNAME, MX Record etc.
$dig www.google.com
- Route Command
It is used to show and manipulate the IP routing table.
There are multiple paths available to communicate over a network.This information is dynamically provided by routers.We can have a specific path to communicate by configuring it manually.
To show the routing table
$route -n
To add a new route
$route add -net<network_address>gw<gateway><interface_name>
Similarly to delete, use del in place of add.
To show the routing table
$route -n
To add a new route
$route add -net<network_address>gw<gateway><interface_name>
Similarly to delete, use del in place of add.
Comments
Post a Comment