Networking Forums

Networking Forums > Computer Networking > Linux Networking > Iptables nat port manipulation problem

Reply
Thread Tools Display Modes

Iptables nat port manipulation problem

 
 
Perry Whelan
Guest
Posts: n/a

 
      05-12-2004, 01:41 AM
Oi!

I, for the life of me, cannot figure out why the included code-snip is
not performing the following:

I want to be able to "ssh Box_A -p 44" and have it forward that to
Box_B's ssh port.

#######SNIP
# Box_A = $IP0 (single NIC)
# Box_B = $IP1

$IPTABLES -A FORWARD -i $IF0 -o $IF0 -d $IP0 -p tcp \
--dport 44 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -t nat -A PREROUTING -i $IF0 -p tcp -d $IP0 \
--dport 44 -j DNAT --to $IP1:22

$IPTABLES -t nat -A POSTROUTING -o $IF0 -j MASQUERADE

$IPTABLES -t nat -A POSTROUTING -o $IF0 -j SNAT --to $IP0
#######SNIP

Thanks,
- Perry
 
Reply With Quote
 
 
 
 
/dev/rob0
Guest
Posts: n/a

 
      05-12-2004, 05:35 AM
On Tue, 11 May 2004 18:41:24 -0700, Perry Whelan wrote:
> I want to be able to "ssh Box_A -p 44" and have it forward that to
> Box_B's ssh port.
>
> #######SNIP
> # Box_A = $IP0 (single NIC)
> # Box_B = $IP1
>
> $IPTABLES -A FORWARD -i $IF0 -o $IF0 -d $IP0 -p tcp \
> --dport 44 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT


Here's the problem. The NAT PREROUTING table has rewritten these
packets. Their destination is now ...

> $IPTABLES -t nat -A PREROUTING -i $IF0 -p tcp -d $IP0 \
> --dport 44 -j DNAT --to $IP1:22


.... $IP1:22. Presumably some other rule or the policy is DROP'ing or
REJECT'ing them. They don't get to the filter FORWARD chain until NAT
PREROUTING has had its way with them.
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables problem with port translation jblumenkrantz@gmail.com Linux Networking 2 10-31-2007 07:46 PM
Problem with port forwarding config (iptables) Daryl Linux Networking 1 02-15-2007 07:54 PM
iptables port redirection problem horvatj Linux Networking 1 01-09-2007 12:50 PM
iptables port redirection problem horvatj Linux Networking 0 01-09-2007 12:24 PM
Nocat - iptables problem (port forwarding) pablo rossi Linux Networking 0 03-04-2004 09:51 AM



1 2 3 4 5 6 7 8 9 10 11