Skip to content

Instantly share code, notes, and snippets.

@matthewblott
Last active April 15, 2022 10:55
Show Gist options
  • Save matthewblott/8696b6a252fcfb9efba05f2927de3066 to your computer and use it in GitHub Desktop.
Save matthewblott/8696b6a252fcfb9efba05f2927de3066 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# allow port 80 (tcp optional)
sudo ufw allow 80
sudo ufw allow 80/tcp
# block port 80
sudo ufw deny 80
# allow 1433 access for specific IP address
sudo ufw allow from 192.168.101.1 to any port 1433
# allow 1433 access for specific IP address with comment
sudo ufw allow from 192.168.101.1 to any port 1433 comment "1433 rule added"
# allow access for subnet
sudo ufw allow from 15.15.15.0/24 to any port 873
# view numbered (easier to delete complicated rule)
sudo ufw status numbered
# delete
sudo ufw delete allow 80
sudo ufw delete 2
# insert rule in particular order (number 1 in this case, if number 1 exists it will become number 2)
sudo ufw insert 1 allow 22
# disable ipv6
sudo vim /etc/default/ufw
IPV6=no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment