Graças ao link acabei criando um script bash para essa tarefa (caso você esteja se perguntando por que loop; o crontab não o executaria por algum motivo):
#!/bin/bash
iptables -t nat -A POSTROUTING -j MASQUERADE
while true
do
LOGFILE=/path/to/ip.txt
Current_IP=$(dig +short @YOUR_NAMESERVER YOUR_DYNDNS_DOMAIN)
# Current_IP=$(host $HOSTNAME | head -n1 | cut -f4 -d ' ')
if [ $LOGFILE = "" ] ; then
iptables -I INPUT -i eth1 -s $Current_IP -j ACCEPT
echo $Current_IP > $LOGFILE
else
Old_IP=$(cat $LOGFILE)
if [ "$Current_IP" = "$Old_IP" ] ; then
echo "IP address has not changed ($Old_IP -> $Current_IP)"
else
iptables -t nat -D PREROUTING -p udp --dport 9989:10050 -j DNAT --to-destination $Old_IP:9989-10050
iptables -t nat -D PREROUTING -p tcp --dport 10011 -j DNAT --to-destination $Old_IP:10011
iptables -t nat -D PREROUTING -p tcp --dport 30033 -j DNAT --to-destination $Old_IP:30033
iptables -t nat -A PREROUTING -p udp --dport 9989:10050 -j DNAT --to-destination $Current_IP:9989-10050
iptables -t nat -A PREROUTING -p tcp --dport 10011 -j DNAT --to-destination $Current_IP:10011
iptables -t nat -A PREROUTING -p tcp --dport 30033 -j DNAT --to-destination $Current_IP:30033
sysctl net.ipv4.ip_forward=1
iptables-save
echo $Current_IP > $LOGFILE
echo "IP address has changed ($Old_IP -> $Current_IP)"
fi
fi
sleep 30
done