wesleymauricio
(usa Debian)
Enviado em 28/09/2010 - 13:13h
Estou precisando criar um firewall para liberar msn por MAC.
A unica duvida é como colocar os MACs em um arquivo e definir uma variavel no script do firewall para liberar os mesmos.
Preciso que seja assim pois são muitos MACs e se for liberar MAC por MAC vou ter que criar muitas regras no script do firewall e tbm não pode ser no squid tem que ser com iptables.
Tentei da forma abaixo, mas gera o seguinte erro:
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Bad mac address `/etc/squid/macs'
Try `iptables -h' or 'iptables --help' for more information.
o script é mais ou menos assim:
#!/bin/bash
iniciar(){
MAC1='/etc/squid/macs'
#POLITICA PADRAO DROP
iptables -P OUTPUT DROP
iptables -P INPUT DROP
iptables -P FORWARD DROP
#Liberando o Ping pra internet
iptables -A OUTPUT -p icmp --icmp-type 8 -s 192.168.1.132 -d 0/0 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -d 192.168.1.132 -j ACCEPT
#Liberando o Ping pra rede externa
iptables -A OUTPUT -p icmp --icmp-type 8 -s 192.168.0.1 -d 192.168.0.0/24 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 0 -s 192.168.0.0/24 -d 192.168.0.1 -j ACCEPT
#Liberando loopback
iptables -A OUTPUT -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -d 127.0.0.1 -j ACCEPT
#Liberando consultas DNS para o servidor
iptables -A OUTPUT -p udp -s 192.168.1.132 --sport 1024:65535 -d 0/0 --dport 53 -j ACCEPT
iptables -A INPUT -p udp -s 0/0 --sport 53 -d 192.168.1.132 --dport 1024:65535 -j ACCEPT
#Liberando acesso http para o servidor
iptables -A OUTPUT -p tcp -s 192.168.1.132 --sport 1024:65535 -d 0/0 --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 80 -d 192.168.1.132 --dport 1024:65535 -j ACCEPT
#Liberando acesso ssl para o servidor
iptables -A OUTPUT -p tcp -s 192.168.1.132 --sport 1024:65535 -d 0/0 --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 443 -d 192.168.1.132 --dport 1024:65535 -j ACCEPT
#Liberando acesso ftp para o servidor
iptables -A OUTPUT -p tcp -s 192.168.1.132 --sport 1024:65535 -d 0/0 --dport 21 -j ACCEPT
iptables -A INPUT -p tcp -s 0/0 --sport 21 -d 192.168.1.132 --dport 1024:65535 -j ACCEPT
#liberando msn rede 192.168.0.1 (FORWARD POR MAC)
iptables -A FORWARD -s 0/0 -p udp --sport 6891:6900 -m mac --mac-source $MAC1 -j ACCEPT
iptables -A FORWARD -m mac --mac-source $MAC1 -d 0/0 -p udp --dport 6891:6900 -j ACCEPT
iptables -A FORWARD -s 0/0 -p tcp --sport 6891:6900 -m mac --mac-source $MAC1 -j ACCEPT
iptables -A FORWARD -m mac --mac-source $MAC1 -d 0/0 -p tcp --dport 6891:6900 -j ACCEPT
iptables -A FORWARD -s 0/0 -p udp --sport 1863 -m mac --mac-source $MAC1 -j ACCEPT
iptables -A FORWARD -m mac --mac-source $MAC1 -d 0/0 -p udp --dport 1863 -j ACCEPT
iptables -A FORWARD -s 0/0 -p tcp --sport 1863 -m mac --mac-source $MAC1 -j ACCEPT
iptables -A FORWARD -m mac --mac-source $MAC1 -d 0/0 -p tcp --dport 1863 -j ACCEPT
}
parar(){
iptables -F
iptables -F -t nat
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os parametros start, stop ou restart!"