[x] Welcome to LinuxSolved.com Linux help forums, here we are a community of Linux users helping each other. It is helpful to both ie. new linux users as well experienced one. We always have our experts to help you and ofcourse members help each other, so you can ask for help any time by Registering.: Click to Register

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Linux Forums - Linux Help,Advice & support community:LinuxSolved.com  |  Forum  |  Linux in General  |  Linux Tutorials & How To's  |  Topic: Internet Sharing in Linux / NAT How to
Welcome to LinuxCommunity

You have just arrived to a friendly linux community which is helping Linux Users from Years.. You can be its part if you have not already joined it. Registration is FREE and is gateway to unlimited help and support to all your linux related needs. If you are an GNU/Linux supporter then you have come to the right place.
Pages: [1] 2 3
  Print  
Author Topic: Internet Sharing in Linux / NAT How to  (Read 55678 times)
0 Members and 1 Guest are viewing this topic.
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« on: January 08, 2004, 12:40:46 PM »

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


Now save this rc.nat in /etc/rc.d/ and make it executable by
Code:
chmod 755 /etc/rc.d/rc.nat


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


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.
Logged
digimart
New Member

Offline Offline

Posts: 3


View Profile WWW
« Reply #1 on: January 08, 2004, 01:38:28 PM »

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 ?
Logged
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« Reply #2 on: January 09, 2004, 11:30:48 AM »

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
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.
Logged
amith
Linux Noob !
*
Offline Offline

Posts: 4


View Profile
« Reply #3 on: January 13, 2004, 11:37:50 PM »

I will try now all the squid configuration and i will b back/b> :lol:
Logged
ozioma
Tux Awared
**
Offline Offline

Posts: 35


View Profile
« Reply #4 on: May 22, 2004, 08:06:59 AM »

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
Logged
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« Reply #5 on: May 22, 2004, 10:56:55 AM »

You are pretty new.. it is very simple.. if u want to do it from command line then can use vi.. ie. to make rc.nat do " vi rc.nat" then it will open a new file.. type stuff i mentioned and then save it using
":save /etc/rc.d/rc.nat"

or u can use graphical editor..
Logged
ozioma
Tux Awared
**
Offline Offline

Posts: 35


View Profile
« Reply #6 on: May 22, 2004, 11:25:03 AM »

PLEASE IS THERE ANY WAY I CAN BROWSE THE INTERNET FROM MY WORKSTATION WITHOUT SETTING THE CLIENTS GATEWAY AS THE IP ADDRESS OF THE SERVER LIKE CIM MY FORMER SERVER ALL WE NEEDED DO WAS CONFIGURE THE INTERNET EXPLORER TO USE PORT 8080 AND THEN PUT THE IP OF THE SERVER WITHOUT CONFIGURING THE GATEWAY

THANKS

OZIOMA
Logged
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« Reply #7 on: May 22, 2004, 11:21:07 PM »

If you are looking for that then you need squid proxy. see Squid proxy configuration.
BTW you can also set dhcp server on ur linux box so that you don't have to configure every box. Just set your clients to obtain ip and other information from dhcp server. See DHCP server linux how to

Lastly I suggest you to read some stuff about networking to clear your concepts..
Logged
kisakye
Linux Noob !
*
Offline Offline

Posts: 4


View Profile
« Reply #8 on: May 30, 2004, 09:20:26 AM »

hi everyone am still wondering after writing out that script which ricky gave will my box linux be able to work as a server hence work with windows machines on the  network??
thanks
Logged
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« Reply #9 on: May 30, 2004, 09:24:13 AM »

Yes , I can be gateway for any machine on any OS untill that machine uses universal TCP/IP protocol
Logged
JOJ
New Member

Offline Offline

Posts: 1


View Profile
« Reply #10 on: June 24, 2004, 08:55:09 PM »

javascript:emoticon(%27%3Acry%3A%27). Hi everyone there.... I am connecting to Internet through Very Small Sperture Terminal (VSAT), and according to our ISP it will only work in Windows Servers. I have a lot of problems dealing with my windows now. Presently I have Slackware Linux running connected to our LAN but it will still connect to windows for Internet. Thus, I want to replace my windows server with Slackware. Is it possible to configure VSAT with Linux?. How?. Please help me. Yes please coz I want to get rid off my windows as soon as possible.

Thanks a lot.

Begginner
Logged
tomamodi
Linux Learner
***
Offline Offline

Posts: 78


View Profile
« Reply #11 on: August 08, 2004, 02:08:54 PM »

please i
for line in /etc/rc.d/rc.local

this line is enough    /etc/rc.d/rc.nat

or with touch  command

touch /etc/rc.d/rc.nat

still i am not succedded
Logged
Ricky
LST CareTaker
Specially Skilled
*****
Offline Offline

Gender: Male
Posts: 2377


View Profile
« Reply #12 on: August 09, 2004, 03:22:08 AM »

well you can create directory using mkdir or also using touch then put that above script in that directory !!
Logged
anil_garg5
Linux Learner
***
Offline Offline

Posts: 71


View Profile
« Reply #13 on: August 13, 2004, 07:30:17 AM »

Nice ..really good one.

Ricky, I implement this ...working fine.

Kindly guide us ...

Thanks a lot
Logged
Cytomatrix
New Member

Offline Offline

Posts: 1


View Profile WWW
« Reply #14 on: August 27, 2004, 05:40:01 AM »

If i am using slackware as my linux gateway for my windows PCs, how do i open ports for my windows. I play halo (a online game) and counter strike. How do i open ports for my windows application. Another thing, my ISP binds Mac address. If my mac address is wrong i won't able to connect to internet. I can register upto 3 mac addresses, but i can only connect one computer at a time. Will i able to use this technic to share internet.
thanks  Cheesy
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Search LS
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 09, 2010, 11:05:33 AM

Login with username, password and session length
Navigation
Recent Discussions
[September 06, 2010, 03:51:09 PM]

[September 06, 2010, 07:59:34 AM]

[September 03, 2010, 11:45:53 AM]

[September 02, 2010, 06:21:15 AM]

[September 02, 2010, 03:14:25 AM]

[August 31, 2010, 08:30:56 AM]

[August 31, 2010, 01:03:31 AM]

[August 31, 2010, 12:53:38 AM]

[August 31, 2010, 12:43:01 AM]

[August 22, 2010, 05:55:23 AM]
Members
Total Members: 7757
Latest: vikas1980
Stats
Total Posts: 9561
Total Topics: 2751
Online Today: 12
Online Ever: 128
(April 10, 2010, 10:24:17 PM)
Users Online
Users: 0
Guests: 10
Total: 10
Privacy Policy| Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Theme & TinyPortal v0.9.8 © Bloc