Networking Forums

Networking Forums > Computer Networking > Linux Networking > netfilter can we snat port numbers like ip address

Reply
Thread Tools Display Modes

netfilter can we snat port numbers like ip address

 
 
muruga
Guest
Posts: n/a

 
      12-13-2006, 09:21 AM
Hi all,

will the rule work?

iptables -t nat -A POSTROUTING -i eth1 -p udp --dport 1024 -j
MASQUERADE --to-port 1024

can i instruct iptables to nat all ougoing packets arriving on a
praticular port to go only out of router on this port only
(when i receive udp pkt on port no 1024 from eth0 should snat and go
out from eth1 interface on port 1024 only)

can any one help

 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      12-13-2006, 11:43 AM
Hello,

muruga a écrit :
>
> will the rule work?
>
> iptables -t nat -A POSTROUTING -i eth1 -p udp --dport 1024 -j
> MASQUERADE --to-port 1024


No. You cannot use -i (input interface) in the POSTROUTING chain. Did
you mean -o (output interface) ?

> can i instruct iptables to nat all ougoing packets arriving on a
> praticular port to go only out of router on this port only
> (when i receive udp pkt on port no 1024 from eth0 should snat and go
> out from eth1 interface on port 1024 only)


I am not sure I understand what you want exactly. Please clarify when
you mean source or destination port. This rule masquerades the original
source IP address and replaces the original source port with 1024. Is
this what you want ? Be aware that in case of multiple connections it
may cause packets to be dropped because of connection tracking "collisions".

If you want to mangle the source port only and not the source IP
address, use the SNAT target instead :

iptables -t nat -A POSTROUTING -i eth1 -p udp --dport 1024 \
-j SNAT --to-source :1024
 
Reply With Quote
 
muruga
Guest
Posts: n/a

 
      12-13-2006, 12:18 PM
Hi,
sorry i need this
iptables -t nat -A POSTROUTING -o eth1 -p udp --dport 1024 -j
MASQUERADE --to-port l024

what i want is any udp packet received on 1024 port should go out or
the router on 1024 port(the router to sent out from 1024 on wan
interface eth1)

 
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
Remote Admin 2.1 and Port Numbers/Firewall? John Home Networking 0 04-10-2008 04:44 PM
netfilter: Redirecting incoming udp packets to other port muruga Linux Networking 0 12-11-2006 04:56 AM
Decoding Port Numbers Kerry Broadband Hardware 1 10-02-2004 11:25 AM
What port numbers and type (TCP or UDP) do I need to open for VPN Spin Windows Networking 9 09-17-2004 11:27 PM
Private and public port numbers Fred Hervieux Windows Networking 1 10-26-2003 12:27 AM



1 2 3 4 5 6 7 8 9 10 11