1

Automate whitelisting ip addresses in iptables in bash

view story
linux-howto

http://serverfault.com – I am looking for the best way to automate whitelisting IP addresses into iptables. The list of ip addresses and ports comes from a JSON file which is formatted like: [ { "ip": "1.2.3.4", "protocol": "tcp", "port": 3306 }, { "ip": "2.4.5.6", "protocol": "tcp", "port": 80 }, { "ip": "5.6.7.8", "protocol": "tcp", "port": 443 }, { "ip": "6.8.3.1", "protocol": "tcp", "port": 53 } ] I need a BASH script which reads the json file and creates ALLOW iptables rules. Example allow rules based on the json above looks like: iptables -A INP (HowTos)