IP=$(hostname -I) # IP address of the Raspberry PI. iptables -A INPUT -p tcp --dport 8080 -s 192.0.2.1 -j ACCEPT iptables -A INPUT -p tcp --dport 8080 -s 127.0.0.1/255.0.0.0 -j ACCEPT iptables -A INPUT -p tcp --dport 8080 -s $IP -j ACCEPT iptables -A INPUT -p tcp --dport 8080 -j REJECT