TimeLinux1

Wednesday, February 23, 2011

Linux: Routing basics

Routing is the process of defining the rules and mechanism of moving a packet of data from one host to another. Routing follows rules called 'routes' that live in a hosts kernel in a routing table -- a fancy word for a set of routes. In tcp/ip, a host needs only know the next hop or next intermediate host a packet will travel en way to its destination.


-routing types:
    . static    - fixed rules defined by sa
    . dynamic    - dynamic rules driven by protocols
-routing protocls:
    . dist vector   - gossipy protocols; every router advertises self. eg rip, ripng, bgp, eigrp
    . link state    - routers observe traffic and keep log of rules. eg ospf, isis.
-dist vector prots are more prone to errors as things change but req less bandwidth and cpu time.

-cost metric:
    . a metric for the router to determine the most efficient path.
    . it measures hops, latency, bandwidth etc.

-rip     - routing info prot, an ipv4 distance vector prot based on an older xerox prot.
-rip uses hop count as a cost metric. current version of rip is ripv2.
-ripng    - an ipv6 version of rip. rip'next gen'
-if a system needs to support both ipv4 and v6, then rip and ripng need to run separately.
-rip is simple and prolific, thats why has survived for long. works for small n/w better.

-ospf    - open shortest path first, is a link state prot. 'open' => non-proprietary.
-uses internal alogrithm to decide the shortest path.
-ospf version 2 is for ipv4.
-ospf version 3 includes ipv6.
-ospf works well with large n/w;
-it doesnt have a standard cost metric, each vendor has its own - cisco has a bandwidth related default value.

-eigrp is enhance interior g/w routing prot.
-eigrp is cisco specific prot, its proprietary, supports ipv6; is evolved like ospf.
-eigrp has no known linux/unix implementations, runs only on cisco.
-isis  is and iso prot, an answer to ospf, less common than ospf.
-bgp   is border gateway prot and is quite popular internet backbone prot.

-You can setup a new subnet with as little as a linux kernel, a n/w card and a switch (all <$200).
-yet dedicated routers are simpler, faster and more reliable (even if they run linux kernel inside).

-some routing daemons:
    . routed  -  old, chatty yet simple. speaks only rip, no ripng.
    . gated   -  old, elegant yet extinct bec it changed course from opensource to a consortium.
    . quagga  -  opensource, multi prot (rip, ospf, bgp, isis), multi os (linux, sun..), popular.
-quagga is named after an extinct species of zebra.
-quagga is the chosen routing prot on linux.
-quagga runs as central 'zebra' daemon that manages individual daemons for the supported prots like ripd, ospfd etc.

-cisco routers are the backbone of the internet with over 60% marketshare.
-cisco routers run proprietary cisco ios.
-ios runs in two modes - user & privileged - both passw protected.

--Misc--

-linux is fast in adopting new changes to n/w configs.
-after network setup changes, ifdown/ifup or reboot are reqd.
-linux flavors run a network management tool called 'networkmanager'. it is useful for laptops.
-ubuntu runs nmgr by default, redhat doesnt.
-network file location:
    . red hat  -    /etc/sysconfig/network
    . ubuntu   -    /etc/network

-to query and set network parameters for an interface use the cmd 'ethtool'.
-changes made by ethtool are transient.
-To set them perm, set them in the interface files in /etc dir.
-tunable network kernel parameters are found in files in /proc/sys/net dir.
-to protect against dos/smurf attacks:
    # echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
-to set ip forwarding (routing):
    # echo 1 > /proc/sys/net/ipv4/ip_forward
-The above are transient as /proc fs is virtual.
-To set them perm, set them in /etc/sysctl.conf

-nat    - using a range of ip addr to multiplex traffic on one ip.
-pat    - using a range of ports   to multiplex traffic on one ip.
-pat is a subset of nat. linux implements pat.
-nat/pat leads pkts from Internet to come/go to one ip addr.
-the host performing nat converts external pkts to internal addr and vice versa.
-to set/modify pat or nat, iptables cmd is used.

No comments:

Post a Comment