LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   source port (https://www.linuxquestions.org/questions/linux-networking-3/source-port-738561/)

OrC82 07-08-2009 05:53 AM

source port
 
Hi,
I'm using iptables.
i need to create a rule for specific IP, that all traffic to this IP will go from specific source PORT.
it is possible ?
for example:
tcp 0 0 192.168.50.82:22 192.168.50.159:3057 ESTABLISHED

I need that port 3057 will be constant for this ip 192.168.50.159

OrC82 07-08-2009 07:20 AM

please anyone....
any ideas ??

XavierP 07-08-2009 07:25 AM

Per the LQ Rules, please do not bump your own thread until at least 24 hours have elapsed without a reply. Because the LQ membership is global, people in other time zones may not have seen this post yet, and thus it may take some time before a response is received.
http://www.linuxquestions.org/rules.php

centosboy 07-08-2009 07:26 AM

Quote:

Originally Posted by OrC82 (Post 3600755)
Hi,
I'm using iptables.
i need to create a rule for specific IP, that all traffic to this IP will go from specific source PORT.
it is possible ?
for example:
tcp 0 0 192.168.50.82:22 192.168.50.159:3057 ESTABLISHED

I need that port 3057 will be constant for this ip 192.168.50.159


if i understand the question correctly -

Code:

iptables -I INPUT -p tcp -s 192.168.50.159 --sport 3057 -d 192.168.50.82 --dport 22 -j ACCEPT

gratuitous_arp 07-08-2009 12:35 PM

Your explanation is a little hard to follow.

Code:

iptables -t nat -A POSTROUTING -p tcp --source 192.168.50.159/32 -j SNAT --to-source 192.168.50.159:3057
This will take the source IP address and port of 192.168.50.159:any-tcp and change it to 192.168.50.159:3057-tcp for any packet that leaves the machine (as long as it is an exact match of the specified IP address). You would enter this rule on the box that has an IP of 192.168.50.159. You could make another rule for udp.


All times are GMT -5. The time now is 06:31 AM.