Network Configuration and Troubleshooting Commands
The PCs and devices which are a part of the network can “talk” to one another and exchange data. In addition the PCs and gadgets which are connected, different devices are frequently required for the system to work properly. A Local Area Network (LAN) interfaces PCs which are near one another. Building a LAN is simpler than connecting different neto (to what is called Wide Area Network). The biggest inter network is known as the Internet.
PCs are joined in a network to exchange information or resources one another. Two or more PC connected through network media called computer network. To set a system suitable media is needed. This can be wired or remote. Twisted-pair, co-axial or fiber-optic are samples of link and infra-red, blue-tooth, radio-wave, micro-wave and so on are remote media utilized for networking. When you are working with an insignificant LAN, PCs, media and peripherals are sufficient. In any case, when you are working with a wider range you have utilize some extra devices like bridge, gateway or route to interface different small or large networks.
ifconfig
ifconfig remains for “interface configuration”. It is utilized to view and change the configuration of the network interfaces on your system. With this command you can see IP Address and Hardware/ MAC address assign to interface further more MTU (Maximum transmission unit) size.
# ipconfig
Output:
eth0 Link encap:Ethernet HWaddr 36:1D:6E:FF:B4:07 inet addr:192.168.10.43 Bcast:192.168.10.255 Mask:255.255.255.0 inet6 addr: fe80::341d:6eff:feff:b407/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:26366 errors:0 dropped:0 overruns:0 frame:0 TX packets:6919 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:13934364 (13.2 MiB) TX bytes:449359 (438.8 KiB) Interrupt:20 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:1101 errors:0 dropped:0 overruns:0 frame:0 TX packets:1101 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:96888 (94.6 KiB) TX bytes:96888 (94.6 KiB)
In any case, to show information of a particular system interface like eth0 , simply type:
# ipconfig eth0
Output:
eth0 Link encap:Ethernet HWaddr 36:1D:6E:FF:B4:07 inet addr:192.168.10.43 Bcast:192.168.10.255 Mask:255.255.255.0 inet6 addr: fe80::341d:6eff:feff:b407/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:26366 errors:0 dropped:0 overruns:0 frame:0 TX packets:6919 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:13934364 (13.2 MiB) TX bytes:449359 (438.8 KiB) Interrupt:20
Configure an Interface
These configurations can consolidated in a single command. Case in point, to configure interface eth0 to use the static IP address, netmask and broadcast address, then use the following command:
# ifconfig eth0 192.168.10.48 netmask 255.255.255.0 broadcast 192.168.10.2
Assign only a static IP address to an interface, specify the interface name and the IP address.
# ifconfig eth0 192.168.10.48
To assign a network mask to an interface, use the keyword netmask and the netmask address.
# ifconfig etho netmask 255.255.255.0
To assign a broadcast address to an interface, use the keyword broadcast and the broadcast address.
# ifconfig etho broadcast 192.168.10.3
Enable or Disable Interface
You can use ifconfig to change the status of a network interface from inactive to active, or vice-versa. To enable an inactive interface use up keywork and to disable an active interface use down keyword.
Enable the inactive interface:
# ifconfig eth0 up
Disable the active interface:
# ifconfig eth1 down
Setting MTU Size
By default MTU size is 1500. Sets the maximum IP packet size for this system. The Value variable can be any number from 60 through 4096, depending upon the network interface.
# ifconfig eth0 mtu value
Example:
# ifconfig eth0 mtu 3000
PING Command
PING (Packet INternet Groper) command is the best way to test connectivity between two nodes. Ping is a basic approach to send network information to, and get system information from another PC on a network. It is as often as possible used to test, at the most basic level, whether another system is reachable over a network, and if so, how much time it takes for that data to be exchanged.
# ping 8.8.8.4
Output:
PING 8.8.4.4 (8.8.4.4) 56(84) bytes of data. 64 bytes from 8.8.4.4: icmp_seq=1 ttl=44 time=84.2 ms 64 bytes from 8.8.4.4: icmp_seq=2 ttl=44 time=81.0 ms 64 bytes from 8.8.4.4: icmp_seq=3 ttl=44 time=80.3 ms 64 bytes from 8.8.4.4: icmp_seq=4 ttl=44 time=80.7 ms
You can also ping domain name also.
# ping www.techoism.com
Output:
PING www.techoism.com (67.225.171.8) 56(84) bytes of data. 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=1 ttl=49 time=231 ms 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=2 ttl=49 time=231 ms 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=3 ttl=49 time=231 ms 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=4 ttl=49 time=230 ms
In Linux ping command keep executing until you interrupt. Ping with -c option exit after N number of request.
# ping -c 3 www.techoism.com
Output:
PING www.techoism.com (67.225.171.8) 56(84) bytes of data. 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=1 ttl=49 time=231 ms 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=2 ttl=49 time=231 ms 64 bytes from svr154.fastwebhost.com (67.225.171.8): icmp_seq=3 ttl=49 time=231 ms --- www.techoism.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2231ms rtt min/avg/max/mdev = 231.117/231.214/231.407/0.571 ms
TRACEROUTE Command
The Internet is an large and complex collection of network hardware, connected together by gateways. Traceroute command is a network diagnostic tool for showing the route packets take to network host or destination. It indicates how long each hop will takes and what number of hop that the packet requires to reach the specify destination.
# traceroute www.techoism.com
Output:
traceroute to www.techoism.com (67.225.171.8), 30 hops max, 60 byte packets 1 192.168.10.19 (192.168.10.19) 0.623 ms 0.565 ms 0.548 ms 2 180.211.97.49 (180.211.97.49) 1.798 ms 1.772 ms 1.745 ms 3 202.131.102.137 (202.131.102.137) 1.786 ms 1.684 ms 1.728 ms 4 202.131.101.77 (202.131.101.77) 1.691 ms 1.658 ms 1.617 ms 5 static-221.65.93.111-tataidc.co.in (111.93.65.221) 2.172 ms 2.931 ms 3.242 ms 6 121.241.90.69.static-ahmedabad.vsnl.net.in (121.241.90.69) 1.728 ms 2.072 ms 2.241 ms 7 172.29.211.217 (172.29.211.217) 16.074 ms 16.056 ms 11.534 ms 8 ix-0-100.tcore1.MLV-Mumbai.as6453.net (180.87.38.5) 42.744 ms 16.038 ms 15.997 ms 9 if-2-2.tcore2.MLV-Mumbai.as6453.net (180.87.38.2) 205.211 ms 204.846 ms 205.023 ms 10 if-6-2.tcore1.L78-London.as6453.net (80.231.130.5) 195.622 ms 195.577 ms 202.540 ms 11 if-7-2.thar1.NJY-Newark.as6453.net (66.198.70.25) 212.014 ms 203.996 ms if-4-2.thar1.NJY-Newark.as6453.net (80.231.130.34) 200.219 ms 12 if-1-3.thar2.NJY-Newark.as6453.net (216.6.57.2) 207.442 ms 204.905 ms 205.712 ms 13 if-14-14.tcore2.NTO-New-York.as6453.net (66.198.111.126) 203.925 ms 200.535 ms 197.195 ms 14 66.110.96.5 (66.110.96.5) 205.638 ms 203.884 ms 201.640 ms 15 66.110.96.150 (66.110.96.150) 206.403 ms 66.110.96.134 (66.110.96.134) 209.831 ms 66.110.96.146 (66.110.96.146) 204.219 ms 16 he-5-10-0-0-cr01.newyork.ny.ibone.comcast.net (68.86.84.249) 199.922 ms he-5-3-0-0-cr01.newyork.ny.ibone.comcast.net (68.86.83.101) 203.808 ms he-5-10-0-0-cr01.newyork.ny.ibone.comcast.net (68.86.84.249) 209.206 ms 17 be-10206-cr01.350ecermak.il.ibone.comcast.net (68.86.86.226) 228.357 ms 228.326 ms 228.299 ms 18 he-0-12-0-1-pe03.350ecermak.il.ibone.comcast.net (68.86.86.22) 226.148 ms 222.071 ms 223.949 ms 19 50.242.150.126 (50.242.150.126) 220.079 ms * 50.242.150.130 (50.242.150.130) 221.460 ms 20 lw-dc3-core1-te8-16.rtr.liquidweb.com (209.59.157.244) 231.375 ms 234.539 ms 233.977 ms 21 lw-dc3-dist13-po5.rtr.liquidweb.com (69.167.128.73) 230.574 ms 228.013 ms 225.895 ms
NETSTAT Command
netstat (network statistics) is a command line tool for monitoring network connections both incoming and outgoing as well as viewing routing tables, interface statistics etc.
# netstat -r
Output:
Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.10.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 default 192.168.10.28 0.0.0.0 UG 0 0 0 eth0
DIG Command
Dig remains for “domain information groper”. Dig provide query DNS related information like A Record, CNAME, MX Record etc.
# dig www.techoism.com
Output:
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6_6.3 <<>> www.techoism.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11472 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.techoism.com. IN A ;; ANSWER SECTION: www.techoism.com. 299 IN A 67.225.171.8 ;; Query time: 119 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Mon Jun 22 17:08:13 2015 ;; MSG SIZE rcvd: 50
NSLOOKUP Command
nslookup, which remains for "name server lookup", is a valuable tool for finding out information about a named domain. By default, nslookup will translate a domain name to an IP address (or vice versa).
# nslookup www.techoism.com
Output:
Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: www.techoism.com Address: 67.225.171.8
ROUTE Command
route command by default will show the details of the kernel routing table entries.
# route
Output:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.10.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 1002 0 0 eth0 default 192.168.10.19 0.0.0.0 UG 0 0 0 eth0
HOST Command
host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa.
# host www.techoism.com
Output:
www.techoism.com has address 67.225.171.8
ARP Command
arp which remains for "Address Resolution Protocol". ARP is useful to view/add the contents of the kernel’s ARP tables.
# arp -e
Output:
Address HWtype HWaddress Flags Mask Iface 192.168.10.28 ether 00:1c:f0:98:07:3a C eth0 192.168.10.43 ether 36:1d:6e:ff:b4:07 C eth0 192.168.10.57 ether b8:2a:72:b0:33:1e C eth0
ETHTOOL Command
When you execute ethtool command with a device name, it displays the following information about the ethernet device.
# ethtool eth0
Output:
Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: Symmetric Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes
HOSTNAME Command
The hostname command is used to show or set a computer's host name and domain name. It is one of the most basic of the network administrative utilities.
# hostname
Output:
server.techoism.com