Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am having trouble with how to configure ufw firewall for my Ubuntu 13.04 VPS server. Each time I enable the firewall, it closes all connections to the server. I need to open the following ports. I have installed LAMP and PhpMyadmin, Mono-complete and nano (as my text editor). I need to open non-standard ports as I am running opensimulator.

First set of rules (allow)

Second set of rules (deny out)

sudo ufw deny out 1:19/tcp
sudo ufw deny out 1:19/udp
sudo ufw deny out 25:52/tcp
sudo ufw deny out 25:52/udp
sudo ufw deny out 54:79/tcp
sudo ufw deny out 54:79/udp
sudo ufw deny out 81:122/tcp
sudo ufw deny out 81:122/udp
sudo ufw deny out 124:442/tcp
sudo ufw deny out 124:442/udp
sudo ufw deny out 444:8999/tcp
sudo ufw deny out 444:8999/udp
sudo ufw deny out 9010:99999/tcp
sudo ufw deny out 9010:99999/udp
sudo ufw deny out 10001:65535/tcp
sudo ufw deny out 10001:65535/udp

If someone could guide me through how to get this done it would be greatly appreciated as I can't understand why it's not working.

share|improve this question

1 Answer 1

To check your current settings:
sudo ufw status verbose

To add basic firewall rules:

sudo ufw deny 5353/udp
sudo ufw deny 5900/tcp
sudo ufw deny 22
sudo ufw deny 25/tcp
sudo ufw deny 135,139,445/tcp
sudo ufw deny 137,138/udp
sudo ufw deny 110
sudo ufw deny 2049
sudo ufw deny 143
sudo ufw deny 21/tcp
sudo ufw deny ssh

To block Outgoing Ports Except Those Needed (This configuration will allow the following outbound ports: 20-21, 53, 80, 123, 443 which is all that is required for many users):

sudo ufw deny out 1:19/tcp
sudo ufw deny out 1:19/udp
sudo ufw deny out 22:52/tcp
sudo ufw deny out 22:52/udp
sudo ufw deny out 54:79/tcp
sudo ufw deny out 54:79/udp
sudo ufw deny out 81:122/tcp
sudo ufw deny out 81:122/udp
sudo ufw deny out 124:442/tcp
sudo ufw deny out 124:442/udp
sudo ufw deny out 444:65535/tcp
sudo ufw deny out 444:65535/udp

Re-check your changes:

sudo ufw status verbose

Re-check enable (required):

sudo ufw enable

share|improve this answer
    
Thank you for your answer it has partially answered my question. In the rules above half of the incoming ports are missing (8000:8010, 9003, 9050:9055) and in the first set of rules it says deny ssh/22 would that not stop me being able to connect using putty. Are there any ubuntu consultants I can hire to configure it for me. It's important that I get it right as I'm using the server at present with all ports open (using shut down to block the ports when I'm not using it - not a good solution I know but I can't get ufw configured properly). I'm happy to pay for this to be done. –  user230293 Jan 1 at 16:06
    
@user230293 I guess, I can refer you here : thefanclub.co.za/how-to/…. Also, if I helped you, you can up vote my answer or can select it as accepted answer. Thanks. –  ASCIIbetical Jan 1 at 17:35
    
That was very helpful if i could ask you to explain the 1st set of rules above (as i understand the logic to the deny out rules and have amended them to reflect the ports that in need open): in the first set of rule the ports I want opened you are using deny 22/23 etc and the first two port numbers 5353/udp and 5900/tcp what do these ports do and why would i need them open. If I can understand what the rules are doing I think i may be able to get it working. –  user230293 Jan 6 at 4:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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