more_ufw_commands_and_examples
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| more_ufw_commands_and_examples [2016/07/24 19:15] – created walkeradmin | more_ufw_commands_and_examples [2016/07/24 19:22] (current) – walkeradmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== More UFW Commands and Examples ====== | ====== More UFW Commands and Examples ====== | ||
| - | + | \\ | |
| - | + | \\ | |
| - | + | Most of this information was acquired from // | |
| - | + | \\ | |
| - | + | \\ | |
| + | Having setup a basic firewall (I say basic, but it's also very effective) there might be a need to create some more complex configurations, | ||
| + | \\ | ||
| + | \\ | ||
| Let’s look at the simple syntax first. Say, for example, you want to allow traffic on port 22 (SSH). To do this with UFW, you’d run a command like: | Let’s look at the simple syntax first. Say, for example, you want to allow traffic on port 22 (SSH). To do this with UFW, you’d run a command like: | ||
| - | sudo ufw allow 22 | + | \\ |
| + | | ||
| + | \\ | ||
| NOTE: I added sudo to the command because you must have admin privileges to run ufw. If you’re using a distribution that doesn’t take advantage of sudo, you’d first have to su to root and then run the same command (minus sudo). | NOTE: I added sudo to the command because you must have admin privileges to run ufw. If you’re using a distribution that doesn’t take advantage of sudo, you’d first have to su to root and then run the same command (minus sudo). | ||
| + | \\ | ||
| Conversely, say you want to prevent traffic on port 22. To do this, the command would look like: | Conversely, say you want to prevent traffic on port 22. To do this, the command would look like: | ||
| - | sudo ufw deny 22 | + | \\ |
| + | | ||
| + | \\ | ||
| Should you want to add a protocol to this, the command would look like: | Should you want to add a protocol to this, the command would look like: | ||
| - | sudo ufw deny 22/tcp | + | \\ |
| + | | ||
| + | \\ | ||
| What happens if you don’t happen to know the port number for a service? The developers have taken that into consideration. UFW will run against / | What happens if you don’t happen to know the port number for a service? The developers have taken that into consideration. UFW will run against / | ||
| - | sudo ufw allow ssh | + | \\ |
| + | | ||
| + | \\ | ||
| Pretty simple, right? You can also add protocols to the above command, in the same way you did when defining a rule via port number. | Pretty simple, right? You can also add protocols to the above command, in the same way you did when defining a rule via port number. | ||
| - | sudo ufw allow ssh/tcp | + | \\ |
| + | | ||
| + | \\ | ||
| + | \\ | ||
more_ufw_commands_and_examples.1469387756.txt.gz · Last modified: (external edit)
