LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 09-22-2002, 09:40 AM   #1
davebarnes
LQ Newbie
 
Registered: Dec 2000
Location: Derbys, UK
Distribution: RedHat, Slackware
Posts: 29

Rep: Reputation: 15
IPTables - again (port mapping)


Hi
IPTables is driving me nuts!

Heres my situation:

A box with Slackware with a NIC (eth0) and a modem (ppp0)
eth0 has IP of 192.168.0.102/16
ppp0 always gets static IP from my ISP

I also have another box with Redhat 7.3 with one NIC (eth0)
Its IP is 192.168.0.101/16
Its running httpd on port 80

I want to be able to access the web server from outside my network - and its not working - even tho I've read loads of stuff in LQ and elsewhere (which is why its driving me nuts!)

On my firewall box, I've tried the following rule...

iptables -t nat -A PREROUTING -s ! 192.168.0.0/16 -i ppp0 -p tcp --dport 80 -j DNAT --to-destination 192.168.0.101:80

...which it seems to accept happily (tho not sure I need to -s bit??)

Without this rule, when I try and connect from outside I get "Connection refused" which makes sense (no httpd on the firewall box)

With the rule, the browser says its connecting, and sits there forever.
Outgoing connections are all masqueraded fine with no problems (there are also 3 other machines on my LAN)


My guess is I'm blatantly being thick and missing something.
Any quick pointers much appreciated


-Dave
 
Old 09-22-2002, 09:52 AM   #2
davebarnes
LQ Newbie
 
Registered: Dec 2000
Location: Derbys, UK
Distribution: RedHat, Slackware
Posts: 29

Original Poster
Rep: Reputation: 15
Now I'm annoyed - I was being thick!
But I have sorted it out (2 minutes after posting! Typical eh?)

I hadn't allowed any rules in the FORWARD chain, and my policy was DROP

Oh well - every day is a school day

PS - I did
iptables -A FORWARD -p tcp --dport 80 -d 192.168.0.101 -j ACCEPT

Last edited by davebarnes; 09-22-2002 at 09:58 AM.
 
Old 09-23-2002, 07:48 AM   #3
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
With the -s ! local bit,
use the inbuilt rp_filter, reverse path, which does this before netfilter sees the packets.

Add this to a script...

for interface in /proc/sys/net/ipv4/conf/*/rp_filter; do
/bin/echo "1" > ${interface}
done

Regards,
Peter

Last edited by peter_robb; 09-23-2002 at 07:50 AM.
 
  


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
port mapping shoaib Linux - Networking 4 10-09-2004 01:51 PM
IPTABLES Mapping/Forwarding Woes shadowcode Linux - Networking 4 07-23-2003 05:20 PM
Port Forwarding/Mapping jmosher Linux - General 0 07-15-2003 09:52 AM
Port mapping problem ChaosX2 Linux - Networking 6 11-25-2001 02:44 AM
Port Routing/mapping Fuigus Linux - Networking 1 09-14-2001 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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