Saturday, December 23, 2017

Basic networking commands in linux for Beginners

To check the Kernal routing table
# route
Example:
# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use  Iface
default         10.130.187.1    0.0.0.0               UG    0      0        0    eth0
10.130.187.0    *               255.255.255.128 U       0      0        0    eth0
20.20.20.0        *               255.255.255.0     U       0      0        0    rt0_3_0
30.30.30.0        *               255.255.255.0     U       0      0        0    rt0_3_1
40.40.40.0        *               255.255.255.0     U       0      0        0    rt0_3_2
127.0.0.0          *               255.0.0.0             U       0      0        0    lo

To check the Interfaces (Iface)
#ifconfig
Example:
# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1E:C9:DE:B2:3B
          inet addr:10.130.187.31  Bcast:10.130.187.127  Mask:255.255.255.128
          inet6 addr: fe80::21e:c9ff:fede:b23b/64 Scope:Link
          UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
          RX packets:4060 errors:0 dropped:198 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:293816 (286.9 KiB)  TX bytes:1124 (1.0 KiB)
          Interrupt:234 Base address:0x2000

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:16436  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:28 (28.0 B)  TX bytes:28 (28.0 B)

rt0_3_0   Link encap:Ethernet  HWaddr 00:1E:C9:DE:B2:3D
          inet addr:20.20.20.1  Bcast:20.20.20.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

rt0_3_1   Link encap:Ethernet  HWaddr 00:1E:C9:DE:B2:3D
          inet addr:30.30.30.1  Bcast:30.30.30.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

rt0_3_2   Link encap:Ethernet  HWaddr 00:1E:C9:DE:B2:3D
          inet addr:40.40.40.1  Bcast:40.40.40.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

To check the Details of routes present
#ip route
Example:
# ip route
default via 10.130.187.1 dev eth0
10.130.187.0/25 dev eth0  src 10.130.187.31
20.20.20.0/24 dev rt0_3_0  src 20.20.20.1
30.30.30.0/24 dev rt0_3_1  src 30.30.30.1
40.40.40.0/24 dev rt0_3_2  src 40.40.40.1
127.0.0.0/8 dev lo