Eu tenho um arquivo chamado mac.txt e dentro dele contem as linhas IP e MAC separados por ponto e virgula, ex:
192.168.0.10;F0:AF:FF:FE:FA:00
Meu script do firewall contem o seguinte:
#!/bin/bash
for i in `cat /root/mac1.txt`;
do
MACSOURCE=`echo $i | cut -d ';' -f1`
IPSOURCE=`echo $i | cut -d ';' -f2`
iptables -t filter -A FORWARD -d 0/0 -s $IPSOURCE -m mac --mac-source $MACSOURCE -j ACCEPT
iptables -t filter -A FORWARD -d $IPSOURCE -s 0/0 -j ACCEPT
iptables -t filter -A INPUT -s $IPSOURCE -d 0/0 -m mac --mac-source $MACSOURCE -j ACCEPT
iptables -t nat -A POSTROUTING -s $IPSOURCE -o eth0 -j MASQUERADE
done
E acontece o erro :
iptables v1.4.3.1: Bad mac address "192.168.0.10"
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.3.1: host/network `F0:AF:FF:FE:FA:00' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.3.1: Bad mac address "192.168.0.10"
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.3.1: host/network `F0:ADF:FF:FE:FA:00' not found
Try `iptables -h' or 'iptables --help' for more information.
Ja tentei usar também WHILE mas o erro acontece. Ele está pegando as ASPAS no IP e o APOSTROFE (`) no MAC.