LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2009, 05:53 AM   #1
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Rep: Reputation: 0
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
 
Old 07-08-2009, 07:20 AM   #2
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Original Poster
Rep: Reputation: 0
please anyone....
any ideas ??
 
Old 07-08-2009, 07:25 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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
 
Old 07-08-2009, 07:26 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by OrC82 View Post
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
 
Old 07-08-2009, 12:35 PM   #5
gratuitous_arp
LQ Newbie
 
Registered: Jul 2009
Posts: 28

Rep: Reputation: 17
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.

Last edited by gratuitous_arp; 07-08-2009 at 12:38 PM. Reason: Clarification
 
  


Reply

Tags
iptables, port, source



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible for two hosts to use the same source port ? exceed1 Linux - Networking 3 04-06-2009 01:35 AM
How to specify source port when sending UDP packet socialjazz Programming 4 09-19-2006 08:15 PM
Port flooding from unknown source! djkhan77 Linux - Security 5 07-15-2006 08:08 AM
receiving connections from source port 80, why? TheLinuxDuck Linux - Security 1 01-24-2006 09:46 PM
Port Forwarding Based on the Source linuxboy69 Linux - Networking 2 01-06-2004 04:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration