Tutorial

Script iptables mac filter

iptables=”/usr/sbin/iptables”
files=”/usr/local/bin/list.txt”
device=”eth1″

#$iptables -F
cat $files | while read ip_address mac_address nama;
do
echo “allow $ip_address $mac_address $nama”;
$iptables -t filter -A INPUT -i $device -s $ip_address -m mac –mac-source $mac_address -j ACCEPT
$iptables -t filter -A FORWARD -i $device -s $ip_address -m mac –mac-source $mac_address-j ACCEPT
done
echo “deny any from $device”;
iptables -t filter -A FORWARD -i $device -j DROP
iptables -t filter -A INPUT -i $device -j DROP

contoh file list.txt
172.21.1.147    00:02:6F:46:A8:43       anu1
172.21.1.149    00:02:6F:47:97:FC       anu2
172.21.1.153    00:02:6F:4A:11:18       anu3
202.43.255.153  00:1E:90:86:CC:68     anu4
202.43.255.147  00:e0:18:a1:81:54      anu5

Baca Juga:  Realtime Clock NTP Server with Wemos D1 Mini

Leave a Reply

Your email address will not be published. Required fields are marked *