mynode/rootfs/standard/usr/bin/mynode_firewall.sh

88 lines
3.4 KiB
Bash
Raw Normal View History

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'
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'
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'
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'
ufw allow 3001 comment 'allow LndHub HTTPS'
2019-06-15 23:02:44 +00:00
ufw allow 3002 comment 'allow BTC RPC Explorer'
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'
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'
2020-03-21 02:56:53 +00:00
ufw allow 4080 comment 'allow Mempool'
ufw allow 4081 comment 'allow Mempool HTTPS'
ufw allow 5000 comment 'allow LNBits'
2020-08-11 04:08:38 +00:00
ufw allow 5001 comment 'allow LNBits HTTPS'
2019-10-05 01:26:48 +00:00
ufw allow 5353 comment 'allow Avahi'
2019-12-26 05:11:29 +00:00
ufw allow 8899 comment 'allow Whirlpool'
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'
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'
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'
#ufw allow from ::1 comment 'allow from localhost'
2019-12-26 05:11:29 +00:00
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
# 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
exit 0