How to view and edit the ephemeral port range on Linux?
Asked Answered
M

1

26

In my Linux system ephemeral port range is showing different ranges as follows

$ cat /proc/sys/net/ipv4/ip_local_port_range 
32768  61000 

cat /etc/sysctl.conf | grep net.ipv4.ip_local_port_range
net.ipv4.ip_local_port_range = 9000 65500

Which will be the effective ephemeral port range in my system?

Modish answered 17/2, 2015 at 23:44 Comment(1)
Only output of /proc files or sysctl tool will show the actual effective port range. /etc/sysctl.conf may or may not be loaded on boot. In your case it does not match so it is either not loaded or overwritten. /proc tells the truth (so should sysctl net.ipv4.ip_local_port_range)Felten
M
32

Following command will list the ephemeral port range in Linux system

sysctl net.ipv4.ip_local_port_range 

If we don't want to reboot, after editing /etc/sysctl.conf file if we execute following command it will be effective.

sysctl -p /etc/sysctl.conf .

The truth of the matter of effective range is output of

sysctl net.ipv4.ip_local_port_range 

as mentioned by eckes in comment.

Modish answered 18/2, 2015 at 4:45 Comment(2)
For me on Red Hat Enterprise Linux Server release 7.6 (Maipo) the command sysctl doesn't exist. Is there an alternative?Omniumgatherum
@Omniumgatherum Did you try as sudo sysctl.... ?Arndt

© 2022 - 2024 — McMap. All rights reserved.