LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-18-2010, 07:04 PM   #1
blackman890
Member
 
Registered: Oct 2004
Location: Iceland
Posts: 94

Rep: Reputation: 15
IPTables port forwarding using prerouting not working


Hi there.

I was trying to setup port forwarding on my setup.

My network consists of:

Code:
[Server: xxx.xxx.xxx.15]
           |
           |
       [ switch ]
           |
           |
[        eth0:xxx.xxx.xxx.254 ]
[Linux                        ]
[        eth1:yyy.yyy.yyy.156 ]
           |
           |
      { Router }
I ran the following 2 commands:

# iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp --dport 80 -j DNAT --to-destination xxx.xxx.xxx.15:80
# iptables -A INPUT -i eth1 -p tcp -m tcp --dport 80 -j ACCEPT

Yet I am unable to connect.
Are these the correct commands?
I am using IP Masquedering on the same box using the following commands:

Code:
$IPTABLES -P INPUT ACCEPT
$IPTABLES -F INPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F OUTPUT
$IPTABLES -P FORWARD DROP
$IPTABLES -F FORWARD

$IPTABLES -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -m limit --limit 1/s -j LOG --log-prefix '------------OUT-------------'
$IPTABLES -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i eth0 -o eth1 -m limit --limit 1/s -j LOG --log-prefix '-------------IN--------------'
$IPTABLES -A FORWARD -i eth0 -o eth1 -j ACCEPT
$IPTABLES -A FORWARD -j LOG
I don't think there is a hidden firewall in the switch but if these commands are correct, then I may need to contact my ISP and see if they are blocking the commands.

I just wanted to make sure I was not doing some stupid mistake before I try to contact my ISP.


EDIT:
Also, is it possible to forward Port 80 requests to different servers depending on the hostname used to connect, so say yyy.com redirects to server xxx.xxx.xxx.15 while hhh.com redirects to xxx.xxx.xxx.16?


Edit:
Problem lied with the ISP. They were blocking all incoming requests.

Last edited by blackman890; 02-19-2010 at 02:33 PM. Reason: Solved
 
Old 02-18-2010, 07:34 PM   #2
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Quote:
Originally Posted by blackman890 View Post
Hi there.



Yet I am unable to connect.

Can you explain this. Connect to where?
 
Old 02-19-2010, 02:06 AM   #3
mpier
Member
 
Registered: Jan 2008
Location: Poland
Distribution: Slackware, Arch
Posts: 38

Rep: Reputation: 17
Hi,
maybe permit forwarding eth1->eth0 first, then we'll think. Allowing input tcp 80 on eth1 is needles, as you will forward this port, not to connect to.
 
Old 02-19-2010, 02:33 PM   #4
blackman890
Member
 
Registered: Oct 2004
Location: Iceland
Posts: 94

Original Poster
Rep: Reputation: 15
Hi there.

What I am unable to is to connect to the webserver from an outside address from the internet.
After contacting my ISP it seems they are blocking all incoming requests, go figure. So the problem lied elsewhere.

Sorry about all this.
 
  


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 is not working 8080 to 80 linux_man_2004 Linux - Networking 13 04-14-2008 01:10 PM
iptables on router: simple port forwarding not working hamish Linux - Networking 1 10-27-2005 06:06 AM
IPtables port-forwarding not working. Ratclaws Linux - Networking 3 04-12-2005 08:14 AM
iptables port forwarding not working! friendklay Linux - Networking 1 03-23-2005 06:37 AM
Port forwarding with iptables is not working?!! philipina Linux - Networking 1 04-03-2004 03:18 PM

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

All times are GMT -5. The time now is 03:13 AM.

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