LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 04-19-2005, 06:06 PM   #1
Tazix
LQ Newbie
 
Registered: Apr 2005
Posts: 5

Rep: Reputation: 0
Firewall / iptables / tomcat problem


Hi,

I'm trying to get a minimal installation of Fedora Core 3 (no Xwindows) to work with the installed redhat firewall and tomcat (as a non-root user).

Basically... I need the iptables config file to redirect port 80 to port 8080.

After searching on the net... the following commands don't seem to work:

Code:
iptables -t nat -A PREROUTING -d your hostname -p tcp --dport 80 -j REDIRECT --to-ports 8080
nor
Code:
iptables -t nat -I PREROUTING --src 0/0 --dst yourip -p tcp --dport 80 -j REDIRECT --to-ports 8080
(of course I have the correct hostname or ip addresses in those commands).

My iptables config file in /etc/sysconfig is:
Code:
#Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT  [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A  INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
Any info on how to get port 80 to redirect to 8080 (preferably in th iptables config) and work with the standard firewall being operational, would be greately appreciated.

Thanks.
 
Old 04-19-2005, 06:16 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
you need to add an INPUT rule for the redirected packets... for example:

Code:
iptables -t nat -A PREROUTING -p TCP -i eth1 --dport 80 \
-j REDIRECT --to-ports 8080

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -p TCP --dport 8080 -m state --state NEW -j ACCEPT
just my two cents...


Last edited by win32sux; 04-19-2005 at 06:20 PM.
 
Old 04-19-2005, 06:50 PM   #3
Tazix
LQ Newbie
 
Registered: Apr 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for the reply, but that didn't work either.

I only have one NIC (eth0), so I think that's why I can't get nat tables.

After entering those commands (with eth0 instead)... all I see with iptables -L is the filter table chains.... nothing for the nat table. I run tomcat as a tomcat user... and get connection refused when I try to http to it from another machine.
 
Old 04-19-2005, 10:36 PM   #4
lihmin
LQ Newbie
 
Registered: Sep 2003
Location: Singapore
Posts: 23

Rep: Reputation: 15
iptables -t nat -L
 
Old 04-20-2005, 11:06 AM   #5
Tazix
LQ Newbie
 
Registered: Apr 2005
Posts: 5

Original Poster
Rep: Reputation: 0
Ok... I got it working sort of...

I changed the /etc/sysconfig/iptables file to this:
Code:
#Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT  [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A  INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT
and the command line:
Code:
#iptables -t nat -A PREROUTING -p TCP -i eth1 --dport 80 -j REDIRECT --to-ports 8080
And that works.

Now I need to figure out how to get that command line in the config file, since obviously the config file doesn't need the command "iptables bla blah" up to the -A portion.
 
Old 04-20-2005, 12:29 PM   #6
Tazix
LQ Newbie
 
Registered: Apr 2005
Posts: 5

Original Poster
Rep: Reputation: 0
NM... I just put the ip tables command line in the script I made that starts tomcat at boot up time.

Thanks for the replies.
 
  


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
Problem Iptables, Firewall rules. Can anybody help ? ZliTroX Linux - Networking 9 09-06-2004 04:48 PM
IPtables/Firewall problem guygriffiths Linux - Security 2 11-21-2003 07:16 AM
iptables internet to firewall problem. remigus Linux - Networking 2 09-29-2003 01:27 PM
Firewall Rules Problem with Iptables JereBear Linux - Networking 1 06-16-2002 04:28 PM
Strange iptables firewall problem. Bomber Linux - Security 5 01-15-2002 06:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

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