Custom Search

Wednesday, May 21, 2014

Introduction to Network Interfaces and Routing

1)
* When we add an interface (example:eth1, eth0), an entry will get added in routing table.

* So for each interface, you can see an entry in routing table, use "#route" or "#route -n" command to check that.

* Use "#ifconfig" or "#ifconfig -a" command to see all interfaces.

Example:1
------------------

#ifconfig
eth1      Link encap:Ethernet  HWaddr 08:00:27:62:d8:33 
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe62:d833/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:154 errors:0 dropped:0 overruns:0 frame:0
          TX packets:195 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:33691 (33.6 KB)  TX bytes:203733 (203.7 KB)

* For the interface "eth1", you can see following entry in routing table.Please check attached screen-shots.

* This entry means that, the interface "eth1" comes (part of) into the network "192.168.56.0 - 192.168.56.255" and we can assign one of the ip (192.168.56.101) from this network to interface "eth1".

#route
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.56.0    *               255.255.255.0   U     0      0        0 eth1

OR

#route -n
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.56.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1

Example:2
-----------------

#ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:f7:a1:25 
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef7:a125/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:107 errors:0 dropped:0 overruns:0 frame:0
          TX packets:104 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:81127 (81.1 KB)  TX bytes:8873 (8.8 KB)

* For the interface "eth0", you can see following entry in routing table.Please check attached screen-shots.

* This entry means that, the interface "eth0" comes (part of) into the network "10.0.2.0 - 10.0.2.255" and we can assign one of the ip (10.0.2.15) from this network to interface "eth0".

#route
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0

OR

#route -n
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0





Routing
======

* "route" command is used to show/manipulate the IP routing table.

* "route" command by default will show the details of the kernel routing table entries.

* The "Destination" column identifies the 'destination network'. The "Gateway" column identifies the defined gateway for the specified network. An asterisk (* or 0.0.0.0) appears in this column if no forwarding gateway is needed for the network. The "Genmask" column shows the netmask for the network; in this case, it is 255.255.255.0. The "Iface" column shows the network interface.Under the Flags section, the "U" flag means the route is up, and the "G" flag means that specified gateway should be used for this route.

* I also have defined route for "192.168.56.0", which is the network that the "eth1" interface is attached to. It does not require a forwarding gateway because this is the local network (in local network, we can use MAC to send the packet). When packets are sent with in this IP range (192.168.56.0 - 192.168.56.255), then the MAC address of the destination is found through ARP Protocol and the packet will be sent to the MAC address.

* I also have defined route for "10.0.2.0", which is the network that the "eth0" interface is attached to. It does not require a forwarding gateway because this is the local network (in local network, we can use MAC to send the packet). When packets are sent with in this IP range (10.0.2.0 - 10.0.2.255), then the MAC address of the destination is found through ARP Protocol and the packet will be sent to the MAC address.

*
#route -n
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    100    0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.56.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

The First line contains a Destination of default, sometimes shown as 0.0.0.0, which means everything else not already classified. In this case, everything not destined for the "10.0.2.0 network" or the "192.168.56.0 network" or the "192.168.122.0 network" will be sent to the 192.168.10.1 address, which is the forwarding gateway, and the route to the Internet.

*
http://www.thegeekstuff.com/2012/04/route-examples/
http://www.techrepublic.com/article/understand-the-basics-of-linux-routing
http://hscripts.com/tutorials/linux-commands/route.html
http://www.thegeekstuff.com/2012/01/arp-cache-poisoning/







No comments:

Post a Comment