LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-09-2007, 12:59 PM   #1
tamsia
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
Smile Setting up a gateway to internet


Hi All

I am setting my Ubuntu linux BOX as a gateway to share the internet for my private LAN behind my linux BOX.

In front of my BOX there is a GW / Proxy with 216.226.208.1 and my BOX can access the internet ok.

My BOX has 2 eth's. The inside is eth1 with 192.168.10.1 (netmask 255.255.240) and the outside is eth0 with 216.226.208.140( netmask 255.255.255.0)

If the IP address setting is OK How can I share the Internet to my private LAN? What I mean is if all the machines are on the same network i.e. 192.168.100.0 wouldn't it be possible to forward the private LAN traffic thru the Ubuntu Box to the outside GW (216.226.208.1)? How? I have seen the tread on masqueraing, but i dont understand how to go about it.

I can ping only upto the eth1 on the Linux BOX from the private LAN. It does not go past it??? I can ping across on the LAn

Please help me on this. Thanks
 
Old 07-09-2007, 03:26 PM   #2
hazmatt20
Member
 
Registered: Jan 2006
Distribution: FC5, Ubuntu
Posts: 126

Rep: Reputation: 15
A masquerade is usually setup using iptables. Here's a short script that would do most of what you need.

Code:
echo "1" > /proc/sys/net/ipv4/ip_forward
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp

EXTIF="eth0"
INTIF="eth1"

iptables -P INPUT DROP
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -F -t nat

iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
Mostly taken from here http://tldp.org/HOWTO/IP-Masquerade-...-examples.html.

That should be all you need for the initial setup. If you need more like port forwarding, you should read through the howto. Just know that the main part of a masquerade is
Code:
iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
You will also need to setup dhcpd on BOX if you want any computer connected to be setup automatically.
 
Old 07-09-2007, 03:46 PM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
could install firestarter and check the box for 'internet connection sharing' that's the simplest method in Linux..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up gateway jamie_barrow Linux - Networking 2 05-08-2007 06:40 AM
problem setting up internet gateway using iptables sweemeng Linux - Networking 2 07-12-2006 01:59 PM
Setting up gateway to share internet for private LAN muru Linux - Networking 6 09-17-2005 08:08 PM
Setting up an internet gateway with web usage logging jcbeckettnz Linux - Newbie 7 05-03-2005 08:20 AM
Gateway Setting ChangeOfPace Linux - Networking 4 05-05-2004 08:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration