Skip to content

Networking With Bash

Bash is often commonly used in the management and maintenance of servers and clusters. Information pertaining to typical commands used by network operations, when to use which command for which purpose, and examples/samples of unique and/or interesting applications of it should be included

Terminal window
ifconfig

The above command will show all active interface of the machine and also give the information of

  1. IP address assign to interface
  2. MAC address of the interface
  3. Broadcast address
  4. Transmit and Receive bytes

Some example

Terminal window
ifconfig -a

The above command also show the disable interface

Terminal window
ifconfig eth0

The above command will only show the eth0 interface

Terminal window
ifconfig eth0 192.168.1.100 netmask 255.255.255.0

The above command will assign the static IP to eth0 interface

Terminal window
ifup eth0

The above command will enable the eth0 interface

Terminal window
ifdown eth0

The below command will disable the eth0 interface

Terminal window
ping

The above command (Packet Internet Grouper) is to test the connectivity between the two nodes

Terminal window
ping -c2 8.8.8.8

The above command will ping or test the connectivity with google server for 2 seconds.

Terminal window
traceroute

The above command is to use in troubleshooting to find out the number of hops taken to reach the destination.

Terminal window
netstat

The above command (Network statistics) give the connection info and their state

Terminal window
dig www.google.com

The above command (domain information grouper) query the DNS related information

Terminal window
nslookup www.google.com

The above command query the DNS and find out the IP address of corresponding the website name.

Terminal window
route

The above command is used to check the Netwrok route information. It basically show you the routing table

Terminal window
router add default gw 192.168.1.1 eth0

The above command will add the default route of network of eth0 Interface to 192.168.1.1 in routing table.

Terminal window
route del default

The above command will delete the default route from the routing table