LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 07-08-2009, 06:53 AM   #1
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 11
Thanked: 0
source port


[Log in to get rid of this advertisement]
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 is offline  
Tag This Post , ,
Reply With Quote
Old 07-08-2009, 08:20 AM   #2
OrC82
LQ Newbie
 
Registered: Jan 2009
Posts: 11
Thanked: 0

Original Poster
please anyone....
any ideas ??
OrC82 is offline     Reply With Quote
Old 07-08-2009, 08:25 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Kubuntu Karmic Koala
Posts: 17,466
Blog Entries: 4
Thanked: 88
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
XavierP is offline     Reply With Quote
Old 07-08-2009, 08:26 AM   #4
centosboy
Member
 
Registered: May 2009
Location: london
Distribution: centos5/opensuse11
Posts: 563
Thanked: 66
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
centosboy is offline     Reply With Quote
Old 07-08-2009, 01:35 PM   #5
gratuitous_arp
LQ Newbie
 
Registered: Jul 2009
Posts: 10
Thanked: 0
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 01:38 PM.. Reason: Clarification
gratuitous_arp is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 02:35 AM
How to specify source port when sending UDP packet socialjazz Programming 4 09-19-2006 09:15 PM
Port flooding from unknown source! djkhan77 Linux - Security 5 07-15-2006 09:08 AM
receiving connections from source port 80, why? TheLinuxDuck Linux - Security 1 01-24-2006 10:46 PM
Port Forwarding Based on the Source linuxboy69 Linux - Networking 2 01-06-2004 05:44 PM


All times are GMT -5. The time now is 10:01 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration