Pages

Tuesday, March 18, 2014

Route

As we have seen how IP address in a local network are added with arp , in the same way if we need to search for IP address outside of the network we  need to have some thing called gateway/router. A gateway is simply a machine that connects to more than one network and can therefore take packets transmitted within one network and re-transmit them on other networks it is connected to. The Linux command “route”  allows us to view/edit routing information.

[root@vx111a ~]# route -n
Kernel IP routing table
Destination      Gateway           Genmask         Flags Metric Ref    Use Iface
172.16.100.0   0.0.0.0             255.255.254.0   U      0       0        0   eth0
169.254.0.0     0.0.0.0             255.255.0.0      U      1002  0        0   eth0
0.0.0.0           172.16.100.254  0.0.0.0             UG    0       0        0   eth0

What does this mean, this simply means that if a packet to “172.16.100” belong to the local network and will be sent to the correct machines using the arp search but if the packets to machines which are other than “172.16.100” will be sent to Gateway machine “172.16.100.254” which will do the rest of job like finding the machine with the IP address and sending the packet to the machine.

The above is an example of the routing table which will help in determining the gateway or host to send a packet to, given a address. An address pattern is specified by combining an address with a subnet mask. A subnet mask is a bit pattern, usually represented in dotted quad notation, that tells the kernel which bits of a destination to treat as the network address and which remaining bits to treat as a subnet.

subnetwork/ subnet is a range of logical addresses within the address space that is assigned to an organization. Sub netting is a hierarchical partitioning of the network address space of an organization into several subnets.

We can add gateway using the route command like,
route add -net 216.109.0.0 netmask 255.255.0.0 gw 192.168.2.2

$ route -n
Kernel IP routing table
Destination    Gateway       Genmask        Flags Metric Ref Use Iface
169.254.0.0   192.168.2.2  255.255.0.0     UG    0      0      0 eth0
216.239.0.0 192.168.2.3    255.255.0.0     UG    0      0      0 eth0


So if we something like this in our routing table, we can say that address from 169.254.* will be routed using 192.168.2.2 gateway.We can use "route delete" to delete route information from the route table.

More to come , happy learning

No comments:

Post a Comment