Linux in General > Linux Tutorials & How To's

Internet Sharing in Linux / NAT How to

(1/9) > >>

Ricky:
Here we will learn how to configure your linux box to share one internet connection over your lan
First make a file named 'rc.nat' and put the following script in it.

--- Code: ---

  # Defines the location of iptables executables.
iptables=/sbin/iptables
 
  #Clears if any old iptable rules/ policies are there.
iptables --flush -t nat

 # Now we will do Masquerading ie. we are doing NAT.
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

 # Enabling packet forwarding.
echo 1 > /proc/sys/net/ipv4/ip_forward

--- End code ---


Now save this rc.nat in /etc/rc.d/ and make it executable by

--- Code: ---chmod 755 /etc/rc.d/rc.nat
--- End code ---


Now add the following lines in your /etc/rc.d/rc.local so that every time you start your computer it get executed  automatically.

--- Code: ---/etc/rc.d/rc.nat
--- End code ---


Now in your clients make sure you have set the gatway as the ip of your computer which is connected directly to internet and also that you have entered right nameserver (DNS) in the dns list of clients.
Now you should be able to share internet after executing this script.

NOTE :: When you run this script you should also use a good firewall.

digimart:
Thanks for good tip.

Pls advise, that in case we have a internet via satellite setup (One-Way). In it the downlinkis through DVB card, and uplink through dialup modem, and the internet is shared on LAN.

As Linux drivers and front-end for our DVB cards ( Technisat B2C2 chip ), are not available on the net <I hv atleast searched at all places, and not able to find>.

So what I did is that I hv set  2 PCs. PC-1 has dialup modem, and running under linux, whereas PC-2 has DVB card, and running under Winxp.

So will your code work in my case too ?

Ricky:
Well here we are basically doing Network Address Translation.  So if anyone makes request to internet first it get translated as it is from the server itself and when the server receives back the reply it tanslates that it goto its original place from where it was requested.
So you can use that in the modem for uplink but i suggest if you are not able to find the drivers then.. connect your DVB card and modem to winxp computer and then connect your linux box to winxp and then your linux to lan..
Some thing like this..

--- Code: --- Satellite & Modem --> WinXP box --> Linux Box -->  your LAN
--- End code ---
In this setup you can still take full advantage of Linux Flexibility and can keep your LAN secure enough. Also I suggest that you can use your any low end (spare) pc to connect directly to internet.

amith:
I will try now all the squid configuration and i will b back/b> :lol:

ozioma:
PLEASE HOW DO I SHARE MY INTERNET CONNECTION OVER MY LAN WITH MY LINUX SERVER WHAT IS THE COMMAND TO MAKE THE FILE rc.nat AND THE COMMAND TO SAVE IT IN /etc/rc.d/

ALSO HOW DO I EDIT IT

THANKS

OZIOMA

Navigation

[0] Message Index

[#] Next page

Go to full version