2019-06-15 23:02:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
2020-03-05 04:29:58 +00:00
|
|
|
# Make sure we are using legacy iptables
|
|
|
|
update-alternatives --set iptables /usr/sbin/iptables-legacy || true
|
|
|
|
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Add default rules
|
|
|
|
ufw default deny incoming
|
|
|
|
ufw default allow outgoing
|
|
|
|
|
|
|
|
# Add firewall rules
|
|
|
|
ufw allow 22 comment 'allow SSH'
|
|
|
|
ufw allow 80 comment 'allow WWW'
|
2020-03-30 23:19:59 +00:00
|
|
|
ufw allow 443 comment 'allow Secure WWW'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 1900 comment 'allow SSDP for UPnP discovery'
|
2021-02-14 17:58:14 +00:00
|
|
|
ufw allow from 10.0.0.0/8 port 1900 to any comment 'allow UPnP from router'
|
|
|
|
ufw allow from 192.168.0.0/16 port 1900 to any comment 'allow UPnP from router'
|
|
|
|
ufw allow from 172.16.0.0/12 port 1900 to any comment 'allow UPnP from router'
|
2022-03-07 04:06:04 +00:00
|
|
|
ufw allow 9911 comment 'allow Lightning Watchtower'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 10009 comment 'allow Lightning gRPC'
|
|
|
|
ufw allow 10080 comment 'allow Lightning REST RPC'
|
|
|
|
ufw allow 9735 comment 'allow Lightning'
|
2019-12-23 05:46:42 +00:00
|
|
|
ufw allow 8332 comment 'allow Bitcoin RPC - filtered by rpcallowip'
|
2020-02-28 01:25:33 +00:00
|
|
|
ufw allow 8333 comment 'allow Bitcoin mainnet'
|
|
|
|
ufw allow 18333 comment 'allow Bitcoin testnet'
|
|
|
|
ufw allow from 172.17.0.0/16 to any port 28332 comment 'allow Dojo zmqrawblock'
|
|
|
|
ufw allow from 172.28.0.0/16 to any port 28332 comment 'allow Dojo zmqrawblock'
|
|
|
|
ufw allow from 172.17.0.0/16 to any port 28333 comment 'allow Dojo zmqrawtx'
|
|
|
|
ufw allow from 172.28.0.0/16 to any port 28333 comment 'allow Dojo zmqrawtx'
|
|
|
|
ufw allow from 172.17.0.0/16 to any port 28334 comment 'allow Dojo zmqhashblock'
|
|
|
|
ufw allow from 172.28.0.0/16 to any port 28334 comment 'allow Dojo zmqhashblock'
|
2021-02-10 06:00:38 +00:00
|
|
|
ufw allow 8335 comment 'allow corsproxy for btc rpc'
|
2021-03-31 03:09:55 +00:00
|
|
|
ufw allow 8443 comment 'allow Lightning Terminal'
|
2019-11-23 04:27:35 +00:00
|
|
|
ufw allow 2222 comment 'allow WebSSH2'
|
2020-08-18 02:33:34 +00:00
|
|
|
ufw allow 2223 comment 'allow WebSSH2 HTTPS'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 3000 comment 'allow LndHub'
|
2020-08-12 04:22:40 +00:00
|
|
|
ufw allow 3001 comment 'allow LndHub HTTPS'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 3002 comment 'allow BTC RPC Explorer'
|
2020-08-12 04:22:40 +00:00
|
|
|
ufw allow 3003 comment 'allow BTC RPC Explorer HTTPS'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 3010 comment 'allow RTL'
|
2020-08-11 04:08:38 +00:00
|
|
|
ufw allow 3011 comment 'allow RTL HTTPS'
|
2020-06-06 01:46:39 +00:00
|
|
|
ufw allow 3020 comment 'allow Caravan'
|
2020-07-14 04:50:54 +00:00
|
|
|
ufw allow 3030 comment 'allow Thunderhub'
|
2020-08-11 04:08:38 +00:00
|
|
|
ufw allow 3031 comment 'allow Thunderhub HTTPS'
|
2021-12-19 01:17:58 +00:00
|
|
|
ufw allow 3493 comment 'allow Network UPS Tools'
|
2020-03-21 02:56:53 +00:00
|
|
|
ufw allow 4080 comment 'allow Mempool'
|
2020-08-18 01:27:07 +00:00
|
|
|
ufw allow 4081 comment 'allow Mempool HTTPS'
|
2020-06-26 04:30:17 +00:00
|
|
|
ufw allow 5000 comment 'allow LNBits'
|
2020-08-11 04:08:38 +00:00
|
|
|
ufw allow 5001 comment 'allow LNBits HTTPS'
|
2021-12-05 22:11:22 +00:00
|
|
|
ufw allow 5010 comment 'allow Warden Terminal'
|
|
|
|
ufw allow 5011 comment 'allow Warden Terminal HTTPS'
|
2019-10-05 01:26:48 +00:00
|
|
|
ufw allow 5353 comment 'allow Avahi'
|
2021-12-29 18:50:03 +00:00
|
|
|
ufw allow 8010:8019/tcp comment 'allow USB Extras HTTP/HTTPS'
|
2019-12-26 05:11:29 +00:00
|
|
|
ufw allow 8899 comment 'allow Whirlpool'
|
2021-02-10 05:37:43 +00:00
|
|
|
ufw allow 9823 comment 'allow CKBunker'
|
|
|
|
ufw allow 9824 comment 'allow CKBunker HTTPS'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 50001 comment 'allow Electrum Server'
|
|
|
|
ufw allow 50002 comment 'allow Electrum Server'
|
2021-02-10 05:37:43 +00:00
|
|
|
ufw allow 53001 comment 'allow Sphinx Relay'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow 56881 comment 'allow myNode QuickSync'
|
|
|
|
ufw allow 51413 comment 'allow myNode QuickSync'
|
|
|
|
ufw allow 6771 comment 'allow myNode QuickSync (LPD)'
|
2019-11-14 02:32:37 +00:00
|
|
|
ufw allow 19999 comment 'allow Netdata'
|
2020-08-18 02:33:34 +00:00
|
|
|
ufw allow 20000 comment 'allow Netdata HTTPS'
|
2020-07-08 03:13:01 +00:00
|
|
|
ufw allow 25441 comment 'allow Specter Desktop'
|
2020-02-23 05:40:19 +00:00
|
|
|
ufw allow 49392 comment 'allow BTCPay Server-direct'
|
2020-08-18 01:27:07 +00:00
|
|
|
ufw allow 49393 comment 'allow BTCPay Server-direct HTTPS'
|
2019-08-13 03:29:53 +00:00
|
|
|
ufw allow 51194 comment 'allow VPN'
|
2020-02-23 05:40:19 +00:00
|
|
|
ufw allow 61208 comment 'allow Glances'
|
2020-08-18 02:33:34 +00:00
|
|
|
ufw allow 61209 comment 'allow Glances HTTPS'
|
2019-06-15 23:02:44 +00:00
|
|
|
ufw allow from 127.0.0.1 comment 'allow from localhost'
|
2020-03-05 04:30:35 +00:00
|
|
|
#ufw allow from ::1 comment 'allow from localhost'
|
2019-12-26 05:11:29 +00:00
|
|
|
|
2022-06-10 04:47:34 +00:00
|
|
|
# Allow all local traffic
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/local_traffic_allowed ]; then
|
|
|
|
ufw allow from 10.0.0.0/8
|
|
|
|
ufw allow from 192.168.0.0/16
|
|
|
|
ufw allow from 172.16.0.0/12
|
|
|
|
else
|
|
|
|
ufw delete allow from 10.0.0.0/8
|
|
|
|
ufw delete allow from 192.168.0.0/16
|
|
|
|
ufw delete allow from 172.16.0.0/12
|
|
|
|
fi
|
|
|
|
|
2022-04-21 04:07:03 +00:00
|
|
|
# Open ports for additional apps
|
|
|
|
mynode-manage-apps openports
|
|
|
|
|
2019-06-15 23:02:44 +00:00
|
|
|
# Enable UFW
|
|
|
|
ufw --force enable
|
|
|
|
|
|
|
|
# Make sure ufw is enabled at boot
|
|
|
|
systemctl enable ufw
|
|
|
|
|
|
|
|
# Check UFW status
|
|
|
|
ufw status
|
|
|
|
|
2019-08-31 01:17:35 +00:00
|
|
|
# Reload firewall after some time to reset (fixes VPN)
|
|
|
|
sleep 120s
|
|
|
|
ufw reload
|
|
|
|
|
2020-03-30 23:19:59 +00:00
|
|
|
# We don't really want to exit
|
|
|
|
sleep 999d
|
2019-12-26 04:38:30 +00:00
|
|
|
exit 0
|