| Author |
Message |
pic.micro23
Joined: 18 Apr 2009
Posts: 7
|
| Posted: Sat Apr 18, 2009 10:57 pm Post subject: Two IP's and forward a port - help. |
|
|
Hello,
I'm new with iptables but I would like some pointers.
My linode has two ip addresses (ipA and ipB) and I have two processes that I want to expose using port 80 (internally the process run as processA:80 and processB:8080)
So I would like to do this
ipA:80 -> processA:80 (webserver)
ipB:80 -> processB:8080 (test custom webserver)
Any info is appriciated... be gentle :)
Thanks |
|
| Back to top |
|
nknight
Joined: 16 Nov 2008
Posts: 38
|
| Posted: Sun Apr 19, 2009 2:45 am Post subject: |
|
|
There is no reason for iptables to be involved here. Ports are IP-specific, not system-wide. You need to bind your webserver to a specific IP address/port combination rather than blindly binding to all IPs on the system.
Check the documentation for the webserver daemon you're using. If it's Apache, it's the 'Listen' directive you'll want to read about. |
|
| Back to top |
|
fukawi2
Joined: 02 Feb 2009
Posts: 64
Location: Melbourne, Australia
|
| Posted: Wed Apr 22, 2009 12:51 am Post subject: |
|
|
As mentioned, you should be able to get the server(s) to bind on the same port with different IP's... But if you can't (for whatever reason):
Code: iptables -t nat -A PREROUTING -p tcp -m tcp -d XXX.XXX.XXX.XXX --dport 80 -j REDIRECT --to-ports 8080
Replace XXX.XXX.XXX.XX with your second IP. |
|
| Back to top |
|
pic.micro23
Joined: 18 Apr 2009
Posts: 7
|
| Posted: Wed Apr 22, 2009 11:24 am Post subject: |
|
|
Thanks a lot Nknight,Fukawi2.
I used the example of webserver port 80 becuase i thought somebody had run in to it before. BUT that helped understand what the solution was.
I'm using a piece of code that does not have a way to bind to a specific IP (it will be fixed). But now I have a temp solution using iptables until it's fixed.
Thanks for answering these basic questions which made me realized what the real problem was and the temp solution. |
|
| Back to top |
|
| |