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 - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2006, 01:08 PM   #1
zgauthier
Member
 
Registered: Aug 2004
Distribution: Slackware 10.1
Posts: 45

Rep: Reputation: 15
IPTables Nightmare


I've been trying to solve this on my own for a few days now. I'm now at the point where I'm frustrated enough to ask for help. So here's my setup. I've got a machine acting as a bridge using ebtables, as well as acting as a gateway. The bridge simply goes from my school's network to my machines, same subnet, nothing is done with those packets. Now there's also a vpn to another network set up on this same machine. This box acts as a gateway between my machines and this vpn network. In that sense, it's working. However, I need to forward ports to my machines. That is forward them so the people on the vpn network can get to services running on my machines. I can't get this to work. The vpn network is on a completely different subnet, hence the need for nat and port forwarding. Please, if anyone has any experience with itpables and port forwarding, I could really use your help. Below is my current iptables script.


iptables -t nat -A POSTROUTING -o tap0 -j MASQUERADE

iptables -t nat -A PREROUTING -i tap0 -p tcp -j DROP
iptables -t nat -A PREROUTING -i tap0 -p udp -j DROP
iptables -t nat -A PREROUTING -i tap0 -p icmp -j ACCEPT
iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 81 -j DNAT --to 192.168.1.194:81
iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 6000 -j DNAT --to 192.168.1.194:6000
iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 22 -j DNAT --to 192.168.1.194:22
iptables -t nat -A PREROUTING -i tap0 -p tcp --dport 21 -j DNAT --to 192.168.1.194:21

Last edited by zgauthier; 06-10-2006 at 02:59 PM.
 
Old 06-10-2006, 11:05 PM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
I haven't figured out everything you are trying to do, but your PREROUTING rules look very strange. Remember that rules in any chain are tested in sequence until a match is made with a rule containing a jump (-j) command.

In your case, you are *immediately* dropping all udp and tcp packets from tap0. Then you are accepting (*without* DNATing) all icmp packets from that interface. So tcp packets will not even make it to the rules where you actually DNAT!

My guess is you want to either eliminate the first three PREROUTING rules or move them after the DNAT rules.

Last edited by blackhole54; 06-12-2006 at 12:03 AM.
 
Old 06-10-2006, 11:56 PM   #3
EvilC0P
LQ Newbie
 
Registered: Jun 2006
Location: Montreal
Distribution: Fedora Core 4
Posts: 16

Rep: Reputation: 0
and the masquerade line should be last.

but it's more a routing problem you are having imo. it's pretty hard to debug your situation with so little details about ur setup.

you shouldnt have to do any port forwarding, if ppl can ping your machine. since you are in the same network. try putting firewall down to see if it works. service iptables stop
 
Old 06-11-2006, 01:18 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by zgauthier
iptables -t nat -A PREROUTING -i tap0 -p tcp -j DROP
iptables -t nat -A PREROUTING -i tap0 -p udp -j DROP
iptables -t nat -A PREROUTING -i tap0 -p icmp -j ACCEPT
even though i'm having a hard time understanding your situation even after reading your post twice, i do believe you should probably get rid of these three rules...
 
Old 06-11-2006, 11:56 PM   #5
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by EvilC0P
and the masquerade line should be last.
Masquerade is in a different chain, so it doesn't matter where that command is in the script.
 
Old 06-12-2006, 10:15 AM   #6
zgauthier
Member
 
Registered: Aug 2004
Distribution: Slackware 10.1
Posts: 45

Original Poster
Rep: Reputation: 15
Thanks for everyone's input. It was just removing those three lines that did it. I apologize for any confusion about what I'm doing. It's not your ordinary linux router.
 
  


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
iptabes help juanb Linux - Networking 3 10-13-2005 11:36 AM
Gnome Nightmare!!! exvor Linux - General 4 10-29-2004 11:22 AM
My 9600XTR nightmare! Andy@DP Linux - Hardware 2 05-17-2004 03:01 AM
iptabes MaverickApollo Linux - Security 2 12-27-2003 01:37 AM
ML 8.2 Nightmare! descras Linux - General 2 08-22-2002 04:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:42 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