LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Changing ports enoute (https://www.linuxquestions.org/questions/linux-networking-3/changing-ports-enoute-619920/)

Tom Douglas 02-09-2008 10:55 AM

Changing ports enoute
 
In an example log entry below, I'm showing an SPT (I guessing source port) of 32771, and a DPT (guessing destination port) of 53 (DNS).

Why two different ports? Is the port assignment getting changed between the sending NIC and receive NIC? Or am I reading this wrong? I'm wondering how to handle these in my iptables.

Quote:

Rejected: IN= OUT=lo SRC=127.0.0.1 DST=127.0.0.1 LEN=71 TOS=0x00 PREC=0x00 TTL=64 ID=47496 DF PROTO=UDP SPT=32771 DPT=53 LEN=51
Thank you!

Tom D.

ARC1450 02-09-2008 11:36 AM

It's called session multiplexing, if I remember properly.

That's what allows you to open multiple sessions to the same host. For example, when you connect to a web server, if you only connected to and from port 80, you'd only be able to have one session open. That's slow and inefficient. So you hit the same web server from a multitude of source ports, and they all point at port 80; you can get several requests at once from a single web server.

Anyway, it's normal and all good. Generally, you filter your outbound traffic by destination port, or IP. You filter your inbound via source port, or IP. So for a DNS request, you'd want to allow anything out destined for port 53, and anything in sourced from port 53.

Decent explanation?

acid_kewpie 02-09-2008 03:10 PM

well it's not really called anything, that's just the way tcp sockets work.

client / source port numbers are picked generally from an "ephemeral" range, which is a block of space somewhere above port 1024, often way past there, which any process is allowed to open. non-root processes can't open a port under 1024 for security reasons, but essentially there is no relation between a source and destination port (except in some unusal cases like dhcp)

a tcp connection is defined as client_ip:client_port <--> server_ip:server_port and both parties keep track of those 4 attributes (amongst others relevant within that known connection) and so know what connection that is.

ARC1450 02-11-2008 08:32 AM

Yes, it is called multiplexing. Here are a few web sites to describe it.

http://ntrg.cs.tcd.ie/undergrad/4ba2...t/5.cd.03.html
http://www.citap.com/documents/tcp-ip/tcpip013.htm
http://www.tcpipguide.com/free/t_TCP...pplicati-2.htm

It's not "just the way TCP sockets work." It's done for a reason, and a rather good one.

acid_kewpie 02-11-2008 10:13 AM

well i know it's for a reason..! Just that it's such a fundamentally low level piece of TCP/IP, it's not something that you actively look to modify or question to any extent.

ARC1450 02-11-2008 10:21 AM

Sure you question it. That's how you learn. :)

Not to mention, knowing why it does what it does can come in handy later. Take this, for example. The OP had no knowledge of TCP/IP multiplexing, and as far as he knew, his ports were getting switched around en-route.

Imagine when he saw several connections to the same server from different ports. Someone not having knowledge of why this happens could be a little freaked out, and that's never good (although it can be funny.) lol

Personally, I've never accepted, or given a "just because" answer. While you can't change it, in depth knowledge of how something works is much better. Imagine if your phones were set up and the TDM used to separate phone calls was just accepted and never improved upon. You wouldn't have TDM over fiber, you wouldn't really have modems, and you wouldn't have DSL (since it uses frequency division multiplexing). Same with TCP/IP multiplexing; if you don't question how it works, you'll never know how it works, why it works, why it's implemented, and the massive number of uses for it.

Just imagine, as another example, if I just accept QoS for what it is in my job, but had no understanding of it. I'd have 4000 very unhappy VoIP users on my network, and I'd have no clue what was going on.

acid_kewpie 02-11-2008 10:26 AM

ever wished you'd not phrased something the way you had?

qos?

Router(config-if)#auto qos voip
Router(config-if)#

what's to learn?? ;)

if you use Cisco Call Manager like we do, you've probably got 4000 unhappy users whatever you do.

jiml8 02-11-2008 10:47 AM

Quote:

Originally Posted by acid_kewpie (Post 3053500)
ever wished you'd not phrased something the way you had?

LOL. Noooooo. Never! :rolleyes:

ARC1450 02-11-2008 10:47 AM

Not to sound demeaning, but auto qos voip illustrates where "just because" can get you.

While it can be used to QoS a network, it is not the end-all-be-all to QoS solutions, nor should it really be used permanently. It is a tool for base lining the QoS your network should need, and is a suggestion. You can choose to continue using it or not, but it will not always solve your problems. Cisco actually doesn't recommend you implement it as a permanent solution on your network.

Quote:

Yes, auto-qos is allowed in the lab. We used prohibit the usage of this feature, however, the retriction is lifted more than a year ago because it is indeed a useful feature for our customers. With that being said, I recommend you to use auto-qos to asssit you to establish a baseline QoS configuration, then read the lab question requirements carefully to make sure you customize or edit the configs to meet the specific requirements.
Found in this thread regarding CCIE-V from NetPro: http://forum.cisco.com/eforum/servle...lected_message

The post is from BennG.

We actually use CallManagers; around 14 of them. Users are actually rather happy because the network is properly designed and the 6 engineers responsible for it have have in-depth knowledge of networking and the protocols.

Quote:

ever wished you'd not phrased something the way you had?
The story of my life. :(

acid_kewpie 02-11-2008 10:51 AM

Note to self. Never make jokes to ARC1450.

ARC1450 02-11-2008 03:18 PM

I never joke. 100% serious.

Am I serious, or am I joking? The world may never know. ;)

Now see, if you'd have said Unity and Lotus were the bestest of buddies and worked flawlessly together, there's a joke. You'd have had me in stitches for the next 6 months with that. :-P

Keep in mind, I just came off a job with a "network manager" that thought himself a Cisco god. The guy barely knew what QoS stood for, and had absolutely no good words for Cisco's AVVID implementation.

Tom Douglas 02-16-2008 10:58 AM

Quote:

Originally Posted by ARC1450 (Post 3051590)
It's called session multiplexing, if I remember properly.............

Ahh...That makes sense. It had my curiousity.

Now I just have to figure out how to make those adjustments in the firewall.

Thanks much for the help!

Tom D.
Denver, Colorado

acid_kewpie 02-16-2008 11:28 AM

well the source port is *very* seldom deemed "interesting" in firewall rulesets, only the destination.

ARC1450 02-17-2008 06:41 AM

Quote:

Originally Posted by acid_kewpie (Post 3059393)
well the source port is *very* seldom deemed "interesting" in firewall rulesets, only the destination.

Agreed. I actually can't think of any situation I worry about the source port, except in the case of NTP.


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