6 lines of perl using a hashed array and iptables did just fine.