How to enable sharing of internet from Ubuntu


I was busy trying to enable internet sharing on a computer with Ubuntu to other computers having Windows/Ubuntu as OS. I was searching for solution from many days.
One solution i got was Firestarter: Firestarter has the ability to share the firewall host’s Internet connection among all the computers on your local network. This is done through a technique called Network Address Translation, or NAT. To the outside world the cluster of machines will look like a single machine with a single IP address.
but. The Firewall/gateway machine connected to the Internet will need two network cards and the clients need one each if u need to enable internet sharing using firestarter..
So i had to find another solution.. and when i read one of my friends recent post, it helped how to find a solution to any problem by urself, rather knocking others door or searching for solution in a wrong way or style..
Even you can read the post and learn something good to search solutions of problems in better ways:
How to ask questions?

And the solution which helped to solve my above problem(to enable internet sharing on a computer with Ubuntu to other computers having Windows/Ubuntu as OS) is as:

Note: Type all the following commands in a root terminal, DO NOT use sudo.
First be root by typing ‘su’ on terminal and enter your root password..
1. Start by configuring the network card that interfaces to the other computers on you network:
(here in place u can put 0 in place of X if you are using eth0 for LAN connection)
# ifconfig ethX ip

where ethX is the network card and ip is your desired server ip address (Usually 192.168.0.1 is used)

2. Then configure the NAT as follows:

# iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE

where ethX is the network card that the Internet is coming from

# echo 1 > /proc/sys/net/ipv4/ip_forward

3. Install dnsmasq and ipmasq using apt-get:

# apt-get install dnsmasq ipmasq

4. Restart dnsmasq:

# /etc/init.d/dnsmasq restart

5. Reconfigure ipmasq to start after networking has been started:

# dpkg-reconfigure ipmasq

6. Repeat steps 1 and 2.

7: step:
# gedit /etc/sysctl.conf
(see the screenshots below..)
remove the comment(i.e. remove the ‘#’ at the start of the lines) of the lines marked in orange in the screenshots below.


8. Reboot. (Optional)

I hope this helps.