Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-26-2003, 02:51 PM
|
#1
|
|
Member
Registered: Apr 2003
Location: Vail, CO
Posts: 71
Rep:
|
Help! Tring to set up a linux route
Hi, Im tring to set up one of my computers to be a Linux router. I am using iptables to do this.
Here is my setup
eth0 - is my private network 192.168.0.200 mask 255.255.255.0
eth1 - The connection to my university (a public network) 172.22.85.144 255.255.252.0
The way I want it set up, is for it to do the address transaltions for eth0 only. The problem im having is that the gateway is acessible on eth1 and I had some people on eth1 side discover my gateway and use it. What I would like to do is only have it enabled on eth0 and block access to it on eth1
Here is the script I use to configre iptables:
# Delete and flush. Default table is "filter". Others like "nat" must be explici
tly stated.
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
The internet connection here at the dorms is very unstable, this is where I have a problem. Some people found out the I run a ppp (modem) connection when the internet goes down as backup. And they have been taking up my bandwidh. I would like to fix this so I do not have to keep shuting down eth1 everytime the modem starts up.
This is the iptables script I use when Im on the modem:
# Delete and flush. Default table is "filter". Others like "nat" must be explici
tly stated.
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
Thanks,
Marley GPN
|
|
|
|
08-26-2003, 03:06 PM
|
#2
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
For your nat rule try setting the "--in-interface" as well as the "--out-interface"
|
|
|
|
08-26-2003, 03:11 PM
|
#3
|
|
Member
Registered: Apr 2003
Location: Vail, CO
Posts: 71
Original Poster
Rep:
|
This is what happens when I try that
iptables --table nat --append POSTROUTING --in-interface
eth0 -j ACCEPT
iptables v1.2.7a: Can't use -i with POSTROUTING
|
|
|
|
08-27-2003, 01:56 PM
|
#4
|
|
Member
Registered: Apr 2003
Location: Vail, CO
Posts: 71
Original Poster
Rep:
|
Does anyone know how to do this?
|
|
|
|
08-27-2003, 02:04 PM
|
#5
|
|
Member
Registered: Mar 2003
Distribution: Slackware
Posts: 234
Rep:
|
Quote:
|
Some people found out the I run a ppp (modem) connection when the internet goes down as backup. And they have been taking up my bandwidh.
|
that's outstanding, heh.
Is there just one machine you use? you could just only allow your machine's IP (or even MAC if your network uses DHCP) and reject everyone else use of your gateway.
|
|
|
|
08-27-2003, 02:28 PM
|
#6
|
|
Member
Registered: Apr 2003
Location: Vail, CO
Posts: 71
Original Poster
Rep:
|
Here the problem with that. Im new to linux and can't figure out how to do that. If you have any example I would appriciate it if you could post them.
Thanks again
|
|
|
|
08-27-2003, 04:37 PM
|
#8
|
|
Member
Registered: May 2003
Distribution: Ubuntu, Slackware
Posts: 43
Rep:
|
here are the relevant parts of my firewall script, should keep people out of your local network. my network is set up with two internal interfaces eth0 & eth1 and ppp0 as the external interface.
Quote:
echo " clearing any existing rules and setting default policy.."
$IPTABLES -P INPUT DROP
$IPTABLES -F INPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F OUTPUT
$IPTABLES -P FORWARD DROP
$IPTABLES -F FORWARD
$IPTABLES -t nat -F
echo " FWD: Allow all connections OUT and only existing and related ones IN"
echo " Configuring eth0 <-> ppp0"
$IPTABLES -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
echo " Configuring eth1 <-> ppp0"
$IPTABLES -A FORWARD -i $EXTIF -o $INTIF2 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $INTIF2 -o $EXTIF -j ACCEPT
echo " Configuring eth0 <-> eth1"
$IPTABLES -A FORWARD -i $INTIF2 -o $INTIF -j ACCEPT
$IPTABLES -A FORWARD -i $INTIF -o $INTIF2 -j ACCEPT
# This Option should be disabled, it logs all packets in the system log
# $IPTABLES -A FORWARD -j LOG --log-prefix iptables: --log-level notice
echo " Enabling SNAT (MASQUERADE) functionality on $EXTIF"
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
|
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:52 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|