Internet Sharing using a Linux Box

If you have an apple and I have an apple and weof the kernel and network address translation (NAT).
exchange these apples then you and I will still eachFor NATing one can use either ipchains or iptables. It is
have one apple. But if you have an idea and I have anassumed that the private network is in the
idea and we exchange these ideas, then each of us192.168.1.0-255 range.
will have two ideas.-- George Bernard ShawTheLet us take the example of a simple network. The
computer world was similar to all of us having an appleserver is used to connect to the internet. It's IP address
each till some time back. And then the wise men fromis 192.168.1.1. There are 4 workstations 192.168.1.2-5.
the industry made networks. Ideas started flowing allThey are connected to the server via the switch. All
over and soon came in the internet. The internet hasthe workstations share the internet through
been the best thing that has happened to the192.168.1.1The first step is to enable ipforwarding in the
computer world so far. It has created a platformkernel of the server (192.168.1.1).$ vi /etc/sysctl.conf
where we can share our ideas.Since the Internet is aChange the line
large network composed of smaller networks, it madenet.ipv4.ip_forward = 0
sense to break the address space into smaller chunks.to
Network classes enable us to break down thisnet.ipv4.ip_forward = 1This would enable ip
address space. In IPv4 the various classes offorwarding.Then we need to get the server to NAT
networks are -Class A networks have an addresswhich can be done via ipchains or iptables.If ipchains is
range between 1.0.0.1 to 126.255.255.254 and supportused, create a file called rc.fw and add following lines$
16 million hosts on each of 127 networks.vi /etc/rc.d/init.d/rc.fw#!/bin/bash# First Load the
Class B networks have an address range betweenipchains kernel module. Required only if ipchains is
128.1.0.1 to 191.255.255.254 and support 65,000 hosts oncompiled as a module.
each of 16,000 networks./sbin/modprobe ipchains
Class C networks have an address range betweeninsmod ipchains# MASQ the full 192.168.1.0/24 network
192.0.1.1 to 223.255.254.254 and support 254 hosts on/sbin/ipchains -A forward -s 192.168.1.0/24 -j MASQ#
each of 2 million networks.List the rules
Class D networks have an address range between/sbin/ipchains -L -nIf iptables is used instead of
224.0.0.0 to 239.255.255.255 and are reserved foripchains, create a file called rc.fw and add the following
multicast groups.lines -$ vi /etc/rc.d/init.d/rc.fw#!/bin/bash# First Load
Class E networks have an address range betweenthe ipchains kernel module . Required only if iptables is
240.0.0.0 to 254.255.255.254 and are reserved for thecompiled as a module
futureSuch a system makes things simple and/sbin/modprobe iptables
networks are manageable. However, they cannotinsmod iptables# MASQ the full network
communicate with each other. The scenario is very/sbin/iptables -t nat -A POSTROUTING -j
similar to how communities grew around the world.MASQUERADE# List the rules
With time people from different communities needed/sbin/iptables -LThis would look after all the entire data
to communicate with each other, however languagetraffic from the local network to the internet.Finally add
was the barrier. The solution they found was peoplethis to the startup -$ vi /etc/rc.local
who understand both the languages i.e. translators. SoAdd the line
if you need to talk to a beautiful French girl, all you/etc/rc.d/init.d/rc.fwThis ensures that the settings are
need to do is get somebody who understands Frenchretained after a reboot also.After rebooting the server
and can translate English to French and vice versa.would do all the routing functions for the entire
Routers /gateways do the same in computernetwork.On the client side all that is required is to set
networks. Different networks communicate with eachthe default router/gateway as the server's IP i.e.
other using routers.A router allows hosts that are not192.168.1.1. The entire network is now set to share the
on the same logical network, like an IP subnet, tointernet connection.Amarjyoti Krishnan heads
communicate with each other. The router receivesbobcares.com, a tech support company for webhosts
packets (chunks of data) on an interface and routesand ISPs. He is the co-founder of Poornam Info Vision
them to where they need to go based on a routingLtd., a software and IT services company which
table; the table allows the router to have knowledge ofspecializes in Linux based solutions for Webhosts and
where a given logical network is located.Most officesISPs. Poornam Info Vision is an ISO 9001:2000 certified
and homes have small class C private networks.company with a team of over 100 engineers.Amarjyoti
These networks need to communicate with theis a Computer Engineer based in India and has over 7
servers in the internet. The only logical way for them isyears of experience in the hosting industry. He has
to use a gateway/router. Linux has routing functionalityspoken and written extensively on the subject. His
in the kernel itself which makes it an ideal choice for asarticles have been published both online as well as in
routing box.One simple way of sharing the internetprint in magazines.
connection using linux is using the IP forwarding feature