#!/bin/sh
BGPEER_FILE="BGPEERING.IPs"
BGPEER_URL="http://ip.ludost.net/cgi/process?country=1&country_list=BG&format_template=prefix&format_name=&format_target=&format_default="
#######################################################################
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
### DOWNLOAD BG-PEERING IPs ###
wget -T 10 -t 1 -nd -O "/etc/rc.d/firewall/$BGPEER_FILE.tmp" "$BGPEER_URL" >/dev/null 2>&1
if [ "x$?" != "x0" ]; then
rm "/etc/rc.d/firewall/$BGPEER_FILE.tmp"
exit $?
fi
egrep -v '^#' "/etc/rc.d/firewall/$BGPEER_FILE.tmp" > "/etc/rc.d/firewall/$BGPEER_FILE"
rm "/etc/rc.d/firewall/$BGPEER_FILE.tmp"
/etc/rc.d/rc.firewall
До тук добре, но в /etc/rc.d/rc.firewall трябва да имате нещо от типа:
OutI="eth0"
OutIP="192.168.0.150"
iptables="/usr/sbin/iptables"
echo="/bin/echo"
ma="/etc/rc.d/firewall/BGPEERING.IPs"
if [ -f $ma ]
then
printLog "Processing allowed TCP hosts..."
for ip in `cat $ma`
do
printLog "Allowing access to $ip"
$iptables -A INPUT -s $ip -d $OutIP -p tcp -j ACCEPT
done
fi
ma2="/etc/rc.d/firewall/BGPEERING.IPs"
if [ -f $ma2 ]
then
printLog "Processing allowed UDP hosts..."
for ip in `cat $ma2`
do
printLog "Allowing access to $ip"
$iptables -A INPUT -s $ip -d $OutIP -p udp -j ACCEPT
done
fi
# Drop all other incoming traffic
printLog "Will drop and log all other incoming traffic"
$iptables -A INPUT -d $OutIP -p tcp -j DROP
$iptables -A INPUT -d $OutIP -p udp -j DROP
Това е :)
вторник, 28 юли 2015 г.
Малко firewall правила за държава.
Как да забраните достъп до сървъра си от чужбина.
Трябва ви списък с адресите от българското пространство, за целта използвам cron job и си ги тегля на всеки час и рестартирам фаеруола:
Абонамент за:
Коментари (Atom)