#!/bin/bash

# Re6st peers communicate with each other on port 326.
# Port 6696 is used by Babel (routing protocol).
# ( "$ man re6stnet" for more information)

if [ -f /sbin/ip6tables ]; then
  if [ 0 -ne `ip6tables -L | grep -E "(DROP|REJECT)" | wc -l` ]; then
    ip6tables -P FORWARD ACCEPT
    ip6tables -I OUTPUT 1 -p udp --dport 6696 -j ACCEPT
    ip6tables -I OUTPUT 2 -p udp --dport 326 -j ACCEPT
    ip6tables -I INPUT 1 -p udp --dport 6696 -j ACCEPT
    ip6tables -I INPUT 2 -p udp --dport 326 -j ACCEPT
    echo "Updated firewall, openned ports 6696 and 326."
  else
    echo "OK (firewall is disabled)"
  fi
else
  echo "OK (no ip6tables found)"
fi
