From: Javier Martinez <tazok.id0@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Re: Linux ephemeral port range defaults to "broken".
Date: Thu, 7 Aug 2025 16:37:58 +0200 [thread overview]
Message-ID: <c72374b8-19e1-4010-9991-3f9ca20749f6@gmail.com> (raw)
In-Reply-To: <1072bk9$rvl$1@ciao.gmane.io>
[-- Attachment #1.1.1: Type: text/plain, Size: 2479 bytes --]
El 7/8/25 a las 16:01, Grant Edwards escribió:
> On 2025-08-07, Javier Martinez <tazok.id0@gmail.com> wrote:
>
>> Also if you try to use one port from 32768 to one service you will
>> be able to do so if it's not used by any other.
>
> Right, but the problem happens when you do need to bind to a specific
> port (e.g. 44818) and it's already in use as a local ephemeral port.
>
>> Ports below 1024 has root privileges (CAP_NET_BIND_SERVICE) because
>> of this, this services are critical, services from 1024 dont because
>> they are not reserved to root.
>
> True, but not relevent.
>
>> Also, you can restrict using ports with iptables if you need for
>> example. So, if you need this port always available, tell iptables
>> that drop any connection from.
>
> I don't understand.
>
> 1. We don't care what remote source port incoming connections are
> coming from. The remote ports used in connections don't conflict
> with local ports.
>
> 2. Iptables can't prevent a socket from being bound to a particular
> local ephemeral port. I guess if iptables forces the TCP handshake
> to fail, the socket will _probably_ be closed by the application.
>
> The right answer is to use sysctl to reserve specific local ports
> within the ephemeral range via net.ipv4.ip_local_reserved_ports.
>
> I know how the system works. I know how to fix the problem. My
> question was historical: why/how did Linux end up violating the
> standards by default?
>
> --
> Grant
>
>
>
Take note that when you are using DNS, YOU ARE violating the standard
since don't complains with source port randomization. This appeared
because vulnerabilities in DNS protocol and almost all servers implement
it. Every thing done are done for something, and in this case because:
*Users are not admins, so we don't have to reserve them ports
*Reserved ports are just below 1024, no root, no bind
*To assure users surfing for example, we need to give them random ports.
More ports free, more security for web services, dns queries etc
*Resources have to be used, reserving more than 50% of resources for a
"if gets used" is a bad idea
*The resource can be reserved by the admin with iptables if required.
iptables -A OUTPUT -p tcp --sport 55500 -m CONNTRACK --ctstate NEW -j DROP
*Resources must be administrated by admin (a.k.a root), not by lusers
that wants their bittorrent port free if they want
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3145 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
next prev parent reply other threads:[~2025-08-07 14:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 1:38 [gentoo-user] Linux ephemeral port range defaults to "broken" Grant Edwards
2025-08-07 3:49 ` Alexandru N. Barloiu
2025-08-07 6:44 ` Zhixu Liu
2025-08-07 13:04 ` Javier Martinez
2025-08-07 13:12 ` Javier Martinez
2025-08-07 14:01 ` [gentoo-user] " Grant Edwards
2025-08-07 14:25 ` Javier Martinez
2025-08-07 14:37 ` Javier Martinez [this message]
2025-08-10 1:54 ` [gentoo-user] " Grant Taylor
2025-08-10 21:13 ` [gentoo-user] " Grant Edwards
2025-08-10 21:25 ` Javier Martinez
2025-08-10 21:35 ` Grant Edwards
2025-08-10 21:28 ` Grant Edwards
2025-08-10 21:30 ` Javier Martinez
2025-08-10 21:39 ` Grant Edwards
2025-08-10 21:43 ` Javier Martinez
2025-08-10 22:55 ` Grant Edwards
2025-08-10 23:12 ` Javier Martinez
2025-08-10 21:59 ` Javier Martinez
2025-08-10 23:00 ` Grant Edwards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c72374b8-19e1-4010-9991-3f9ca20749f6@gmail.com \
--to=tazok.id0@gmail.com \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox