Gå til hovedinnhold

Firewall ufw på Ubuntu Lucid

Denne nyttige guiden fant jeg her. Den er på engelsk, men hvorfor ikke :)

A new Ubuntu Server install (as of 10.04) contains a firewall (iptables) that is not enabled. Ubuntu.com has a great tutorial that explains that ufw is the default configuration tool for iptables. After I set up my server, I used ufw to close all ports by default, then open up ports for the services I use. I don’t have complex security needs or run a proxy server, so my rules are simple.

Adding Rules

Before adding rules, it’s best to explicitly set the default behavior. By default, I like to block everything: both incoming and outgoing traffic. After that is done, I selectively open ports to support the services I wish to run. In contrast, UFW, by default, denies all incoming traffic but allows all outgoing traffic. That setup is accomplished manually with the following commands.
$ sudo ufw default deny incoming
$ sudo ufw default allow outgoing

The following commands open ports for named services that I use: namely, SSH (port 22), a web server (port 80), and Webmin (port 10000). Any services named in /etc/services may be identified by name instead of port number.
$ sudo ufw allow ssh
$ sudo ufw allow www
$ sudo ufw allow webmin

UFW also has a list of application presets, for common servers such as Apache, OpenSSH, Lighttpd, and Samba. You can view the list by issuing the command:
$ sudo ufw app list
You can implement firewall rules for Samba and Lighttpd by using the commands below, which specify the application name, not the service name. Note that you must enclose in quotation marks any application names that include spaces.
$ sudo ufw allow Samba
It’s better to limit Samba access to hosts on your LAN. Using ufw’s more complex syntax, you can do just that. Note that you have to add “app” before the application name in this case.
$ sudo ufw allow from 10.0.0.0/8 to 127.0.0.1 app Samba
$ sudo ufw allow to 10.0.0.0/8 from 127.0.0.1 app Samba

The following commands open the ports required by my Transmission-Daemon server. Here I must specify port numbers explicitly. Note that you use a colon instead of a dash to specify port ranges. Plus, when creating rules for port ranges, you must specify whether they apply to TCP or UDP.
$ sudo ufw allow 9091
$ sudo ufw allow 20500:20599/tcp
$ sudo ufw allow 20500:20599/udp

The following command opens up ports needed for MySQL, but only to hosts within the local network.
$ sudo ufw allow from 10.0.0.0/8 to any port 3306/tcp
If you wish to open up MySQL to the world, you could use a simpler syntax.
$ sudo ufw allow mysql

Deleting Rules

Deleting rules is pretty simple. Just use the following syntax, and replace <…> with the entire rule that you wish to delete.
$ sudo ufw delete <...>
For example:
$ sudo ufw delete allow ssh
$ sudo ufw delete allow 10000

You can also delete all the rules with a single command.
$ sudo ufw reset

Enabling the Firewall

The following command enables the firewall rules immediately, and upon subsequent system restarts. This command will also refresh the rules. Run this command each time you update your firewall configuration.
$ sudo ufw enable

Disabling the Firewall

To disable the firewall, simply issue the following command.
$ sudo ufw disable

Checking the Configuration

You can check your configuration by issuing one of the following commands. The “verbose” version shows more information.
$ sudo ufw status
$ sudo ufw status verbose

Kommentarer

Populære innlegg fra denne bloggen

Autodownloader for put.io

Downloading files from your put.io archive can be done with wget, it can be done unattended and you won't even have to initiate the job: Place all the files you would like to download in a folder on put.io (i.e /download). Create the script download.sh on your system. Run the script as a cron-job (crontab -e) download.sh #!/bin/sh wget --limit-rate=20k --no-check-certificat -c -nH -P /FOLDER/ -r --ftp-user=USERNAME --ftp-password=PASSWORD ftp://ftp.put.io/download/* --limit-rate=20k will limit bandwith to 20k --no-check-certificat will skip certificate check -c will make wget continue the download if  interrupted   -nH will stop creating the ftp-path in your download-folder -P /FOLDER/ tell wget where to put the downloaded files -r recursive, so that even folders in download will be downloaded --ftp-user=USERNAME Your username to put.io --ftp-password=PASSWORD Your password to put.io (special characters need a backslash i.e PASS\!WORD if your p...

Locales i Ubuntu og andre Debian-spinoffs

"dpkg-reconfigure locales" genererer locales som er listet opp i filen "/var/lib/locales/supported.d/local". Ønsker man å generere flere enn de som allerede er oppført må man derfor legge de til der (en på hver linje) før man kjører "dpkg-reconfigure locales". Godtatt syntaks finnes i filen "/usr/share/i18n/SUPPORTED". Typisk: no_NO.UTF-8 UTF-8 no_NO ISO-8859-1

Helle synger Flashlight (Jessie J) og vinner Talentiaden 2016 på Gudeber...