Skip to contentSkip to conversation

Port forwarding problem...

DISCUSSION DarKRaveR 2 participants 3 messages Feb 11, 2003 1 message not in the archive

lore
Share & tools
lore

DarKRaveR

author
#1 lore raw
In reply to a message not in the archive

Hello Danila,

Shouldn't be a problem, since netfilter takes care before the paket hits anything else, as long as you put your rule in the prerouting chain.
All you wanna do is add something like:

iptables -t nat -A PREROUTING -d realip --dport 33333 -i eth0 -j DNAT --to 192.168.13.147.80

This rewrites the destination address. if you ip is from a dialup connection you might want to use MASQUERADE ...
And make sure you have connection tracking, so the answer packages get rewritten properly.

I think that should do ....
Check out the FAQs there's some nice examples there ...

Tuesday, February 11, 2003, 7:21:30 PM, you wrote:

DO> Hello,

DO> I want to ask you something regarding something that i am stuck in... :-) DO> I need to allow acces to a Web server which runs on a machine inside my LAN. DO> my topology is :

DO> internet <------>(eth0)[web,smtp,pop3,ftp](eth1)<------>LAN(192.168.13.0/24)

DO> i have only one "real" IP on eth0.

DO> can you tell me how can i use something like :

DO> http://www.myserver.xxx:33333 to redirect to .. let's say 192.168.13.147:80 ??

DO> the main problem that i see here is that on port 33333 i have no services running.

DO> Thanxx in advance,
DO> Danila Octavian([email protected])

Signature · 2 lines
Best regards,
 DarKRaveR                            mailto:[email protected]
#3 lore raw
In reply to a message not in the archive
Quoted 8 lines

internet <------>(eth0)[web,smtp,pop3,ftp](eth1)<------>LAN(192.168.13.0/24)

i have only one "real" IP on eth0.

can you tell me how can i use something like :

http://www.myserver.xxx:33333 to redirect to .. let's say

192.168.13.147:80 ??

Quoted 1 line

iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i eth0 -o eth1 -d 192.168.13.147 -j ACCEPT

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 3333 -j DNAT --to-destination 192.168.13.147:80

Quoted 1 line

the main problem that i see here is that on port 33333 i have no

services running.

If port forwarding doesn't work, you don't see a service running on the port.
OTOH if portforwarding works but the service isn't running, the port isn't open on <inet_ip> either.

Gr,
Rob

author
#2 lore raw
In reply to DarKRaveR

Hello Danila,

there's some -p tcp missing cuz we only want that, refer to the mail from Robert (I think) he gave all 3 rules, that should fix your problem ...

Tuesday, February 11, 2003, 8:11:08 PM, you wrote:

D> Hello Danila,

D> Shouldn't be a problem, since netfilter takes care before the paket D> hits anything else, as long as you put your rule in the prerouting D> chain.
D> All you wanna do is add something like:

D> iptables -t nat -A PREROUTING -d realip --dport 33333 -i eth0 -j DNAT D> --to 192.168.13.147.80

D> This rewrites the destination address. if you ip is from a dialup D> connection you might want to use MASQUERADE ...
D> And make sure you have connection tracking, so the answer packages get D> rewritten properly.

D> I think that should do ....
D> Check out the FAQs there's some nice examples there ...

D> Tuesday, February 11, 2003, 7:21:30 PM, you wrote:

DO>> Hello,

DO>> I want to ask you something regarding something that i am stuck in... :-) DO>> I need to allow acces to a Web server which runs on a machine inside my LAN. DO>> my topology is :

DO>> internet <------>(eth0)[web,smtp,pop3,ftp](eth1)<------>LAN(192.168.13.0/24)

DO>> i have only one "real" IP on eth0.

DO>> can you tell me how can i use something like :

DO>> http://www.myserver.xxx:33333 to redirect to .. let's say 192.168.13.147:80 ??

DO>> the main problem that i see here is that on port 33333 i have no services running.

DO>> Thanxx in advance,
DO>> Danila Octavian([email protected])

Signature · 2 lines
Best regards,
 DarKRaveR                            mailto:[email protected]