#!/bin/bash # # add-moolticute-rule # jms1 2019-08-31 # # adds a rule to tails firewall allowing moolticute to connect to moolticuted PORT=30035 if [[ "$(id -u)" != "0" ]] then echo "ERROR: this script must be executed as root" exit 1 fi NUM=$( iptables -vnL OUTPUT --line-numbers | grep "tcp dpt:$PORT" | awk '{print $1}' ) if [[ -n "$NUM" ]] then echo "ERROR: there is already a 'tcp dpt:$PORT' rule in the OUTPUT chain" exit 1 fi NUM=$( iptables -vnL OUTPUT --line-numbers | grep LOG | awk '{print $1}' ) if [[ ! "$NUM" =~ ^[0-9]+$ ]] then echo "ERROR: unable to identify LOG entry in OUTPUT chain" exit 1 fi iptables -I OUTPUT $NUM \ -o lo -p tcp --dport $PORT \ -m owner --uid-owner amnesia \ -j ACCEPT