Your connection to a network is made by your system through a particular hardware interface such as an Ethernet card of a modem. Data passing through this interface is then routed to your network. The ifconfig command configures your network interfaces and the route command sets up the network connections accordingly.
Ifconfig is used to configure the kernel-resident network interfaces.It is used at boot time to set up interfaces as necessary. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only.
Syntax : ifconfig < interface > < -host_net_flag > [address] [options]
where -host_net_flag can be either -host or -net to indicate a host or network IP address.
The -host flag is the default.
#ifconfig eth0 192.168.0.1 => Configuring the Ethernet interface
#ifconfig eth0 192.168.0.1 broadcast 192.168.0.255 netmast 255.255.255.0 => Configuring eth0 including a broadcast address and the netmask
#ifconfig eth0 up => To activate the interface eth0 after configuring it
#ifconfig -a => If a single -a argument is given, it displays the status of all interfaces, even those that are down
Determines where the process starts and to what computer your system needs to send the packet to reach the destination.
#route => To display the routing table
#route add 192.168.1.2 dev eth0 => To route an Ethernet interface
#route del 192.168.1.2 => To delete the route with IP address 192.168.1.2
For a gateway we first need to add a route and then add a route specifying it is a gateway.
#route add 192.168.1.2
#route add default gw 192.168.1.2 => gw here stands for gateway
#route add -net 192.168.23.0 gw dev eth1 => For a gateway to access a subnet
To add an IP address to another network interface we use the ifcofig and route commands with the new IP address.
#ifcofig eth1 192.168.1.3
#route add 192.168.1.3 dev eth1
ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbour for a given IPv4 Address.
#arp -e => Display all ARP table entries for all interfaces
#arp -i eth0 -s 192.168.1.1 00:23:5a:c1:50:99 => Create a static ARP table entry associating IP address 192.168.1.1 with MAC address 00:23:5a:c1:50:99 available through the eth0 interface ( ‘i’ option stands for interface and ‘s’ option is used for setting up new table entry )
#arp -d 192.168.1.1 => Delete the ARP table entry for 192.168.1.1
Traceroute is a utility that traces a packet from your computer to an Internet host showing how many hops the packet requires to reach the host and how long each hop takes.For a slow connection traceroute is used to check the route through which we are connected to a host , monitoring the speed and the number of intervening gateway connections a route takes.
Sample Output for the above command:
traceroute to www.google.com (220.127.116.11), 30 hops max, 60 byte packets
1 172.19.16.1 (172.19.16.1) 1694.355 ms 1694.510 ms 1694.847 ms
2 iws1.iiita.ac.in (172.31.1.1) 0.869 ms 0.864 ms 0.902 ms
3 * * *
4 * * *
5 18.104.22.168.static-Mumbai.vsnl.net.in (22.214.171.124) 66.756 ms 66.750 ms 66.730 ms
6 126.96.36.199.static-pune.vsnl.net.in (188.8.131.52) 69.556 ms 69.287 ms 69.279 ms
7 184.108.40.206 (220.127.116.11) 62.766 ms 62.797 ms 64.210 ms
8 18.104.22.168 (22.214.171.124) 64.153 ms 64.162 ms 65.593 ms
9 126.96.36.199 (188.8.131.52) 65.855 ms 65.849 ms 64.820 ms
10 maa03s04-in-f16.1e100.net (184.108.40.206) 62.011 ms 62.001 ms 61.982 ms
Provides real time information on the status of the network connections, as well as the network statistics and routing table.
#netstat -r => Displays the routing table
#netstat -i => Displays the uses of the different network interfaces.
#netstat -s => Displays protocol( TCP , UDP , IP etc ) counts and errors
To remotely log in to another system on your network. Telnet operates as if we were logging in to another system from a remote terminal and asks for the login name and password.
#telnet hostname < port >
telnet > open hostname < port >
Here the hostname can be either the domain name or the IP address.
Nslookup is a command used to query the Internet domain name servers. Is useful in finding the domain name if the IP is known and vice-versa.
The host command can be used to carry out the same stuff too.
#nslookup < domain name > => To find the dotted decimal IP address of host name
#nslookup < IP address > => To find the hostname of the dotted decimal IP address
Detects whether a system is up and running.
Syntax : ping hostname
where hostname can be either domain name or IP address.
From 172.19.16.47 icmp_seq=1 Destination Host Unreachable
From 172.19.16.47 icmp_seq=2 Destination Host Unreachable
From 172.19.16.47 icmp_seq=3 Destination Host Unreachable
From 172.19.16.47 icmp_seq=4 Destination Host Unreachable
From 172.19.16.47 icmp_seq=5 Destination Host Unreachable
From 172.19.16.47 icmp_seq=6 Destination Host Unreachable
PING 172.19.16.6 (172.19.16.6) 56(84) bytes of data.
64 bytes from 172.19.16.6: icmp_req=1 ttl=128 time=4.00 ms
64 bytes from 172.19.16.6: icmp_req=2 ttl=128 time=4.56 ms
64 bytes from 172.19.16.6: icmp_req=3 ttl=128 time=0.931 ms
64 bytes from 172.19.16.6: icmp_req=4 ttl=128 time=4.10 ms
64 bytes from 172.19.16.6: icmp_req=5 ttl=128 time=1.08 ms
64 bytes from 172.19.16.6: icmp_req=6 ttl=128 time=6.78 ms
Here in the first case the destination host is unreachable whereas in the second case the destination 172.19.6.16 sends the packets back ensuring good connectivity.
ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.
Syntax : ssh username@hostname [command]
where username is your SSH username, and hostname is the host name or IP address of your Web server.
If its the first time we are trying to connect to this host machine we will get a warning saying authentication failure. Typing yes would automatically solve the problem.
#ssh email@example.com -p 1020 => ssh as user raju into 192.168.1.1 port 1020
#ssh firstname.lastname@example.org cd /home/etc => change the directory to /home/etc in the remote server 192.168.1.1