Question

How to open a range ports in debian?

Posted October 19, 2016 27.7k views
DebianDevelopment

Hi,
I don’t cant open a range ports.
For exemple: range: 10000/20000 UPD and open port 5060/UDP, how to make?

Tks, sorry my english!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

Hi @thiago.tda,

If you are trying to open a range ports for firewall follow one of solutions.

In case you are using IPTABLES:

  • sudo iptables -A INPUT -p udp -m udp --dport 5060 -j ACCEPT
  • sudo iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT

It is very probably that you are using IPTABLES so I recommend you to go with it.

If you somehow use ufw following will help:

  • sudo ufw allow 5060/udp
  • sudo ufw allow 10000:20000/udp

Good luck :)

Hello, @thiago.tda

As per @xMudrii reply you can use UFW in order to do that.

UFW, or Uncomplicated Firewall, is an interface to iptables that is geared towards simplifying the process of configuring a firewall. While iptables is a solid and flexible tool, it can be difficult for beginners to learn how to use it to properly configure a firewall. If you’re looking to get started securing your network and are not sure which tool to use, UFW may be the right choice for you.

You can check our full tutorial here for Debian 10:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-debian-10

Allowing Specific Port Ranges

You can specify port ranges with UFW. For example, some applications use multiple ports instead of a single port.

For example, to allow X11 connections, which use ports 6000-6007, use these commands:

sudo ufw allow 6000:6007/tcp
sudo ufw allow 6000:6007/udp

Hope that this helps!
Regards,
Alex

by Hazel Virdó
by Brian Boucheron
by Kathleen Juell
This tutorial will show you how to set up a firewall with UFW on Debian 10.
Submit an Answer