4

I want to limit source port range in my ubuntu machine upto 20000 , that means no Application should be able to use port higher than that.I have this command in mind

iptables -A OUTPUT -p tcp --sport 20001:65535 --dport 20001:65535 -j DROP

But , wouldn't this drop all packets rather than limiting ? I need a configuration such that I can still browse the web , just not through port 20001 to 65535 . No incoming or outgoing through this ports.

3

Edit net.ipv4.ip_local_port_range in /etc/sysctl.conf with:

sudo nano /etc/sysctl.conf

or any other editor of your choice and add or change:

# Allowed local port range
net.ipv4.ip_local_port_range = 1024 20000

Restart your network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.