I am trying to configure UFW (uncomplicated firewall) so that is will deny all ports exept port 443 and 4444. How do i do this?

Dani AI

Generated

Helpful follow-ups and practical checks that complement ’s answer for the “allow only 443 and 4444” goal.

Before switching to a strict policy, remote administration must be preserved so sessions are not lost. Keep an active local/console session or make sure management access (for example SSH from a fixed admin IP or a web-management interface) will remain reachable once rules are applied. Confirm the services actually bind to the intended ports (the firewall only filters packets; the service must be listening).

Quick verification and scanning (run these from the host or from a remote test machine):

ss -ltnp        # list listening TCP sockets and owning processes
netstat -tulpn  # alternative if ss is not available
nmap -Pn -p443,4444 <target-host>   # remote check to confirm reachability

Useful UFW workflow commands and maintenance tips:

ufw status numbered     # shows rules with numbers for easy deletion
ufw logging on          # enable logging to troubleshoot blocked traffic
ufw delete <num>        # remove a rule by its number from the numbered list
ufw reload              # re-apply rules after manual edits

Other practical notes: enable IPv6 support if the host uses IPv6 (check /etc/default/ufw), remember UFW’s default behavior for outgoing traffic (adjust outbound rules explicitly if outbound blocking is desired), and consider using rate-limiting for remote admin ports to reduce brute-force risk. If trouble appears, consult the UFW log (usually /var/log/ufw.log) and the kernel packet-filter tables (iptables/ nftables) for deeper debugging.

Recommended Answers

All 4 Replies

Basically run:

sudo ufw default deny
sudo ufw enable
sudo ufw allow 443/tcp
sudo ufw allow 4444/tcp

and also udp if you need to enable that too. You can list all rules by using:

sudo ufw status

You can read more by using man ufw or reading this document: https://help.ubuntu.com/community/UFW

Aaa thanks, i am kinda new to the linux and setup a firewall thing... So that will make it only eccept connection that hopefully match presefined rules on port 443 and 4444?

Yes, you can also enable a specific IP or a range:

sudo ufw allow from 192.168.0.1 to tcp port 443

Anyway, the link I posted above gives you all the information you need about UFW.

Ok thanks for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.