LinuxQuestions.org
Help answer threads with 0 replies.
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 10-17-2002, 06:27 AM   #1
kofi
Member
 
Registered: Aug 2002
Location: Atlanta
Distribution: Redhat Linux 7.2 & 7.3 + 8.0
Posts: 59

Rep: Reputation: 15
RH7.3 + IPTABLES - Port Forwarding Anyone?


Hey Guys,

Posting this up again. Trying to simply do port forwarding on a RH7.3 box and the bloody thing wont work. I am using the rc.firewall-2.4-stronger script from the IPMasquerading HOWTO from LDP. When I use the rc.firewall-2.4 script which is less strict, I get port forwarding to work but the funny thing is none of my LAN (masqueraded computers) can access any of the services like FTP, SMTP, DNS from the external interface even though suppossedly the kernel 2.4 should work with that.

I just want to know has anyone gotten this to work with Redhat 7.3? Here is my exact script:

rc.firewall-2.4-stronger script

Can anyone tell me where I am going wrong. And yes i did my homework, disabled IPchains completely, made sure i set /proc/sys/net/ipv4/ip_forward to 1 as well as set the FORWARD_IPV4 value in /etc/sysconfig/network to 1. Why RH puts both of them there is beyond me.

Someone please save me, i am going crazy with this simple thing.

Thanks
 
Old 10-17-2002, 09:37 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You did the tests described in the howto? *What* servers can't they reach, local or remote? Example? What does the log say for that example? grep logfile -e "DENY" | grep "(src IP)" | grep "(dest IP)".
Tried logging everything and then try accessing again?

/proc gets values from scripts usually by echoing values to the appropriate key or using sysctl.
 
Old 10-17-2002, 10:55 AM   #3
kofi
Member
 
Registered: Aug 2002
Location: Atlanta
Distribution: Redhat Linux 7.2 & 7.3 + 8.0
Posts: 59

Original Poster
Rep: Reputation: 15
They cant access any of the servers like FTP, WWW, DNS, SMTP on the external Interface.

Basically from a LAN machine I can reach any of these 4 servers only by their private IP address such as 192.168.1.2 for the DNS server and 192.168.1.4 for the WWW server.

I want to be able to get to them from the one external IP address I have hence why I am using port forwarding. The non-strict rc.firewall-2.4 script seems to work with the port forwarding but only if you are coming in from the internet not from the LAN. The stronger script does not forward at all.

When you say log file do you mean /var/log/messages ? I looked in there and there doesnt seem to be any deny entries.

And yes, I did the tests in the HOWTO.. but all the tests seem to be for masquerading which works great but I didnt see any test for the port forwarding.

Thanks for the response. Any thing else II need to do. i am going to try your suggesstion and out the grep statement in there to do some logging.

Will keep you posted. If ya think of anything else, let me know.

Thanks a bunch!
 
Old 10-17-2002, 02:52 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Having logging rules that logs *everything* is good for troubleshooting. That way you can figure out yourself what get's blocked and why. I wish everyone would enable such things during testing.

You mean you would like LAN clients for instance to access your public SMTP server by it's public IP address? Do you have a rule on the input chain allowing access where the dst and src IP are both that of your public address? Cuz that's what you're basically doing, right (translate LAN IP to public IP and then access same public IP)? Wasn't there an example for httpd in the script?

(someone correct me if I'm whorrabwy wonk.)
 
Old 10-17-2002, 04:19 PM   #5
kofi
Member
 
Registered: Aug 2002
Location: Atlanta
Distribution: Redhat Linux 7.2 & 7.3 + 8.0
Posts: 59

Original Poster
Rep: Reputation: 15
Yep, you are right. Exactly! Trying to access SMTP from LAN computers by the public IP.

I am still trying to figure out all what that script is doing cuz I think my problem lies in there somewhere. Did you get a chance to look at it?

Evil Script.. cusing me headaches!!!

Wit regards to logging, do you know any example I can cut and paste to see whats going on? I am going back to the drawing board to read and understand what each line in that script is doing. Thanks for your help, and again if you think of anything let me know.

Thanks!!!
 
Old 10-17-2002, 09:54 PM   #6
Mr IPtables
LQ Newbie
 
Registered: Oct 2002
Posts: 2

Rep: Reputation: 0
I haven't looked at the script but I can tell you how it should work.

This is how the connection will work when inside the lan and trying to port forward from the firewall real ip.

192.168.0.10 -------> firewall internet address -------> port forward --> 192.168.0.20

192.168.0.10 waiting for firewall to reply to SYN with SYN ACK.
192.168.0.20 reply's to 192.168.0.10 directly, packet dropped cause 192.168.0.10 is expecting it from firewall not LAN.

Change your postrouting rules so the lan 192.168.0.20 talks back to the firewall, which then connection tracks it back the other system completing the TCP 3 way connection correctly.

Mr Iptables.
 
Old 10-18-2002, 11:40 AM   #7
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
There are a lot of variables in that firewall.stronger script..
We could have a lot of questions about which modifications you made...
So,
Please do a "service iptables save", rename the /etc/sysconfig/iptables file to say iptables.lq and post it here, (removing your own ip address)
and note which interfaces you are using for LAN and internet please.

It will be much easier to see the end result compared to the original and go from there.
When is the script activated?

Regards,
Peter
 
Old 10-18-2002, 09:34 PM   #8
kofi
Member
 
Registered: Aug 2002
Location: Atlanta
Distribution: Redhat Linux 7.2 & 7.3 + 8.0
Posts: 59

Original Poster
Rep: Reputation: 15
Thanks guys for all the help. Peter_robb, per your suggestion,

here is the result of the "service iptables save:

service iptables save . Also listed that my eth0 is my external IP interface and eth1 is the LAN interface.

The script is activated right after the network cards are enabled. I followed the HOWTO to make sure its the first thing that gets run after the interfaces are brought up.

Thanks a bunch and let me know if you see anything that might fix this. Again, the masquerading part works great. It just wont do port forwarding and neither will you let u access services from the external interface which makes sense if forwarding is not working to begin with.

Let me know.

A much grateful bloke.
 
Old 10-19-2002, 12:08 PM   #9
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Ok,
2 things...

The FORWARD rules are referring to -o interfaces by ip numbers, which don't exist on the firewall...
Usual default behaviour will then be to drop packets because nothing will match them...

And, there isn't a -p udp rule to match dns. Dns will only use tcp if the packets are BIG.

So, I recommend you change those rules first, get something working and then we can fill you in on all the other rules which are missing, eg INPUT policy and protection, Masquerading vs SNAT, /proc/sys/net/ipv4/conf/.../rp_filter etc

Please make a note of which changes/decisions you made in the original script, eg interfaces, dynamic/static numbers, services etc.

Regards,
Peter

Last edited by peter_robb; 10-19-2002 at 12:10 PM.
 
  


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
iptables port forwarding geoff3425 Slackware 13 12-20-2011 10:50 AM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
iptables - port forwarding midiguy732 Linux - Networking 1 11-24-2005 01:40 AM
iptables port forwarding hawk4eye Linux - Security 2 02-07-2003 04:47 AM
Iptables w/port forwarding claytonj25 Linux - Security 8 12-22-2001 08:30 AM

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

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