конвертирование конфига iptables в конфиг ipfw

Операционки на базе Unix
Post Reply
User avatar
Gen1us2k
Модератор
Модератор
Posts: 771
Joined: 02 Mar 2010, 16:13

конвертирование конфига iptables в конфиг ipfw

Post by Gen1us2k » 03 Dec 2010, 13:31

Надо конвертировать.
цель: защита от syn_flood открыть порты только на кг зону
[spoiler]

Code: Select all

#!/bin/sh
#------------------------------------------------------------------------------
# Переменные
#------------------------------------------------------------------------------
IPT='/sbin/iptables' #iptables
MODPROBE="/sbin/modprobe"
ARP="/usr/sbin/arp"
IP6TABLES=/sbin/ip6tables
TC=/sbin/tc
INDEV=ppp0
#------------------------------------------------------------------------------
# Логи наше все
#------------------------------------------------------------------------------
LOG="LOG --log-level debug --log-tcp-sequence --log-tcp-options"
LOG="$LOG --log-ip-options"
#------------------------------------------------------------------------------
# лимит
#------------------------------------------------------------------------------
RLIMIT="-m limit --limit 3/s --limit-burst 8"
#------------------------------------------------------------------------------
# КГ Сетки
#------------------------------------------------------------------------------
aknet='212.112.96.0/19'
asia='195.38.160.0/19'
bitel='194.176.111.0/24'
bmc='85.26.220.0/22'
city='212.2.224.0/19'
comintech='81.20.16.0/20'
elcat1='212.42.96.0/19'
elcat2='77.95.56.0/21'
elcat3='94.143.192.0/21'
kt1='212.241.0.0/19'
kt2='212.97.0.0/19'
kt3='213.145.128.0/19'
kt4='85.113.0.0/19'
kt5='89.237.192.0/18'
mega1='77.235.0.0/19'
mega2='92.245.96.0/19'
nur1='194.152.36.0/24'
nur2='194.152.37.0/24'
energo1='91.205.48.0/22'
energo2='95.215.244.0/22'
saima='217.29.16.0/20'
totel='85.115.192.0/19'
transfer='81.88.192.0/20'
#------------------------------------------------------------------------------
$MODPROBE ip_conntrack_ftp
$MODPROBE ip_conntrack_irc
# Конфигурация ядра
# Включаем IP forwarding.
#------------------------------------------------------------------------------
echo 1 > /proc/sys/net/ipv4/ip_forward
# Включить защиту IP спуфинга
for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 0 > $i; done
# зашита от SYN flood атак
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
# Игнорировать все входящие ICMP echo запросы
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
# Игнорировать ICMP echo запросы на broadcast
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
# Регистрировать пакеты с невозможными адресами.
for i in /proc/sys/net/ipv4/conf/*/log_martians; do echo 1 > $i; done
# Не логгировать invalid ответ на broadcast
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
# Не принимать или отправлять ICMP редиректы.
for i in /proc/sys/net/ipv4/conf/*/accept_redirects; do echo 0 > $i; done
for i in /proc/sys/net/ipv4/conf/*/send_redirects; do echo 0 > $i; done
# Не принимать source routed пакеты.
for i in /proc/sys/net/ipv4/conf/*/accept_source_route; do echo 0 > $i; done
# Disable multicast routing
#for i in /proc/sys/net/ipv4/conf/*/mc_forwarding; do echo 0 > $i; done
# отключить proxy_arp.
for i in /proc/sys/net/ipv4/conf/*/proxy_arp; do echo 1 > $i; done
# Включить Секурные Редиректы, то есть только принимаем ICMP редиректы на шлюзы
for i in /proc/sys/net/ipv4/conf/*/secure_redirects; do echo 1 > $i; done
# Отключить bootp_relay
for i in /proc/sys/net/ipv4/conf/*/bootp_relay; do echo 0 > $i; done
# Правила по умолчанию.
#------------------------------------------------------------------------------
# Дропать все
$IPT -P INPUT DROP
$IPT -P FORWARD DROP
$IPT -P OUTPUT DROP
# Включаем nat/mangle/raw Цепочки принимать пакеты
$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t mangle -P PREROUTING ACCEPT
$IPT -t mangle -P INPUT ACCEPT
$IPT -t mangle -P FORWARD ACCEPT
$IPT -t mangle -P OUTPUT ACCEPT
$IPT -t mangle -P POSTROUTING ACCEPT
# Ебля (зачистка)
#------------------------------------------------------------------------------

# Ебнуть все найух
$IPT -F
$IPT -t nat -F
$IPT -t mangle -F

# Удаляем все
$IPT -X
$IPT -t nat -X
$IPT -t mangle -X

# все обнуляем
$IPT -Z
$IPT -t nat -Z
$IPT -t mangle -Z

# Отключаем IPv6.
#------------------------------------------------------------------------------

# Блочить весь IPv6 Траффик
# если ip6tables Доступна то пытаемся отключить
if test -x $IP6TABLES; then
# По дефолту
# Дропать все
$IP6TABLES -P INPUT DROP 2>/dev/null
$IP6TABLES -P FORWARD DROP 2>/dev/null
$IP6TABLES -P OUTPUT DROP 2>/dev/null

# Таблица mangle может пропустить все
$IP6TABLES -t mangle -P PREROUTING ACCEPT 2>/dev/null
$IP6TABLES -t mangle -P INPUT ACCEPT 2>/dev/null
$IP6TABLES -t mangle -P FORWARD ACCEPT 2>/dev/null
$IP6TABLES -t mangle -P OUTPUT ACCEPT 2>/dev/null
$IP6TABLES -t mangle -P POSTROUTING ACCEPT 2>/dev/null

# Удалить все правила.
$IP6TABLES -F 2>/dev/null
$IP6TABLES -t mangle -F 2>/dev/null

# все цепочки.
$IP6TABLES -X 2>/dev/null
$IP6TABLES -t mangle -X 2>/dev/null

# все обнулить
$IP6TABLES -Z 2>/dev/null
$IP6TABLES -t mangle -Z 2>/dev/null
fi

# А вот тут вот и начинаецца сама ебля с iptables....
#------------------------------------------------------------------------------

# Логгируем и потом принимаем пакеты.
$IPT -N ACCEPTLOG
$IPT -A ACCEPTLOG -j $LOG $RLIMIT --log-prefix "ACCEPT "
$IPT -A ACCEPTLOG -j ACCEPT

# Логгируем и шлем найух.
$IPT -N DROPLOG
$IPT -A DROPLOG -j $LOG $RLIMIT --log-prefix "DROP "
$IPT -A DROPLOG -j DROP

# Логгируем и режектим.
$IPT -N REJECTLOG
$IPT -A REJECTLOG -j $LOG $RLIMIT --log-prefix "REJECT "
$IPT -A REJECTLOG -p tcp -j REJECT --reject-with tcp-reset
$IPT -A REJECTLOG -j REJECT

# Только разрешаем RELATED ICMP типы
$IPT -N RELATED_ICMP
$IPT -A RELATED_ICMP -p icmp --icmp-type any -j ACCEPT
$IPT -A RELATED_ICMP -p icmp --icmp-type time-exceeded -j ACCEPT
$IPT -A RELATED_ICMP -p icmp --icmp-type parameter-problem -j ACCEPT
$IPT -A RELATED_ICMP -j DROPLOG

# против мульти пинга
$IPT  -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j ACCEPT
$IPT  -A INPUT -p icmp -m limit --limit 1/s --limit-burst 2 -j LOG --log-prefix PING-DROP:
$IPT  -A INPUT -p icmp -j DROP
$IPT  -A OUTPUT -p icmp -j ACCEPT

# Разрешить только минимально необходимые / рекомендованные части ICMP. Остальное в пезду
# Дропаем все фрагментированные ICMP пакеты ( почти всегда злоебучие)
#$IPT -A INPUT -p icmp --fragment -j DROPLOG
#$IPT -A OUTPUT -p icmp --fragment -j DROPLOG
#$IPT -A FORWARD -p icmp --fragment -j DROPLOG
# Разрешаем ESTABLISHED ICMP траффик.
$IPT -A INPUT -p icmp -m state --state ESTABLISHED -j ACCEPT $RLIMIT
$IPT -A OUTPUT -p icmp -m state --state ESTABLISHED -j ACCEPT $RLIMIT
# Разрешить не весь RELATED ICMP траффик, остальное блочим
$IPT -A INPUT -p icmp -m state --state RELATED -j RELATED_ICMP $RLIMIT
$IPT -A OUTPUT -p icmp -m state --state RELATED -j RELATED_ICMP $RLIMIT
# Разрешить входящие эхо ICMP запросы (пинг), только с ограничением по конекту
$IPT -A INPUT -p icmp --icmp-type echo-request -j ACCEPT $RLIMIT

# ЗА ПИНГЕ ОТВЕЧАЕМ ХУЛЕ!1 %)
$IPT -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT $RLIMIT

# То что не проходит по правилам Шлем в пезду (или найух, кого куда).
$IPT -A INPUT -p icmp -j DROPLOG
$IPT -A OUTPUT -p icmp -j DROPLOG
$IPT -A FORWARD -p icmp -j DROPLOG
#------------------------------------------------------------------------------
# Не ограничиваем lo
$IPT -A INPUT -i lo -j ACCEPT
$IPT -A OUTPUT -o lo -j ACCEPT
# Пропускаем ESTABLISHED и RELATED пакеты (не знаешь чо это то пиздуй кури маны %))
$IPT -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

# отвечаем, кроме invalid
$IPT -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

# ХУЕТА
#------------------------------------------------------------------------------

# Нам ПОХУЙ на Мелкософт, так что шлем его нахуй... No Windows, no Gates :P
$IPT -A INPUT -p tcp -m multiport --dports 135,137,138,139,445,1433,1434 -j DROP
$IPT -A INPUT -p udp -m multiport --dports 135,137,138,139,445,1433,1434 -j DROP

# Дропаем хуйпонятный Входящий траффик (INVALID)
$IPT -A INPUT -m state --state INVALID -j DROP

# Таже фигня с исходящим
$IPT -A OUTPUT -m state --state INVALID -j DROP

# Если мы будем использовать NAT, INVALID пакеты посылаем на...
$IPT -A FORWARD -m state --state INVALID -j DROP

# АА фиг просканишь порты эжжэ ээээ %)
$IPT -A INPUT -m state --state NEW -p tcp --tcp-flags ALL ALL -j DROP
$IPT -A INPUT -m state --state NEW -p tcp --tcp-flags ALL NONE -j DROP
$IPT -A PREROUTING -i $INDEV -t mangle -p tcp --syn \
  -j MARK --set-mark 1
# а вот тут вот нам будет похуй на школьнегоф %)
$IPT -N SYN_FLOOD
$IPT -A INPUT -p tcp --syn -j SYN_FLOOD
$IPT -A SYN_FLOOD -m limit --limit 2/s --limit-burst 6 -j RETURN
$IPT -A SYN_FLOOD -j DROP
$IPT -A SYN_FLOOD -j REJECT
# есле мудак какой то накосячил то ебем его вот тут..
# $IPT -A INPUT -s АЙПИ_МУДАКА -j DROPLOG

# разрешаем исходящий трафф
$IPT -A OUTPUT -j ACCEPT
# Входяшие DNS запросы
$IPT -A INPUT -m state --state NEW -p udp --dport 53 -j ACCEPT
$IPT -A INPUT -m state --state NEW -p tcp --dport 53 -j ACCEPT
# а вот тут вот уже правила на то что разрешено %)
$IPT -A INPUT -p tcp -m tcp -s $mega1 --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $mega2 --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $elcat1 --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $elcat2 --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $elcat3 --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $city --dport 21 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $aknet --dport 21 -j ACCEPT
#ssh но не всем...
$IPT -A INPUT -p tcp -m tcp -s $aknet --dport 22 -j ACCEPT
#$IPT -A INPUT -p tcp -m tcp -s 92.245.108.200 --dport 22 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $mega1 --dport 22 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $mega2 --dport 22 -j ACCEPT
# открываем HTTP трафф на КГ зону
$IPT -A INPUT -p tcp -m tcp -s $mega1 --dport 80 -j ACCEPT
$IPT -A INPUT -p tcp -m tcp -s $mega2 --dport 80 -j ACCEPT
#iptables -t nat -A POSTROUTING -j MASQUERADE
#$IPT -A INPUT -i eth0 -j ACCEPT
#$IPT -A OUTPUT -o eth0 -j ACCEPT
#NAT to vboxnet0
$IPT -t nat -A POSTROUTING -s 192.168.56.3 -o ppp0 -j SNAT --to-source 77.235.12.36

# Ну и то что мы тут забыли то логируем и отправляем далеко %)
#------------------------------------------------------------------------------
$IPT -A INPUT -j REJECTLOG
$IPT -A OUTPUT -j REJECTLOG
$IPT -A FORWARD -j REJECTLOG
#    exit 0
[/spoiler]
Image
Home: Windows Heaven
Home: Debian 6
For Servers: Debian || RHEL Based || Gentoo || FreeBSD
User avatar
Infernal Flame
Злой Модер
Posts: 1796
Joined: 03 Mar 2010, 11:25
ОС: Centos 7
Contact:

Re: конвертирование конфига iptables в конфиг ipfw

Post by Infernal Flame » 03 Dec 2010, 13:49

эт к Raven'у... он у нас фряшник :)
Image
Image
Work: Centos 7 х 'all Servers'
User avatar
Raven
Бородатый сис
Бородатый сис
Posts: 2794
Joined: 03 Mar 2010, 15:12
ОС: RHEL 8
Location: Из серверной

Re: конвертирование конфига iptables в конфиг ipfw

Post by Raven » 03 Dec 2010, 14:22

Примерно так (настрогал по быстрому на коленке):

Code: Select all

#!/bin/sh
IPFW="/sbin/ipfw"
SCTL="/sbin/sysctl"
EXT="tun0" #В случае pppoe внешний интерфейс будет именно такой. ifconfig тебе в помощь
EXT_IP="твой статичный ип (ну или грепай динамику)"
INT="rl0"
INT_IP="192.168.0.10"
LAN="192.168.0.0"
LAN_MSK="24"


#Уменьшаем время ожидания ответного пакета на запрос SYN-ACK
${SCTL} net.inet.tcp.msl=7500
#Превращаем сервер в черную дыру (снижает нагрузку на машину во время DDoS а на случайные порты):
${SCTL} net.inet.tcp.blackhole=2
${SCTL} net.inet.udp.blackhole=1
#Ограничиваем число ответов на ICMP-сообщения 50-ю в секунду
${SCTL} net.inet.icmp.icmplim=50
#Увеличиваем максимальное количество подключений к серверу (защита от всех видов DDoS):
${SCTL} kern.ipc.somaxconn=32768
#Включай DEVICE_POLLING в ведре - существенно снизит нагрузку на систему во время DDoS
#Пересобирай ядро с опцией «options DEVICE_POLLING»
#Врубаешь: «sysctl kern.polling.enable=1» (можно вписать тремя строками выше) либо
#Добавь запись «kern.polling.enable=1» в /etc/sysctl.conf.

#Чистим перышки
${IPFW} -f flush
${IPFW} -f pipe flush
${IPFW} -f queue flush

${IPFW} add check-state

#Разрешаем все для lo
${IPFW} add allow ip from any to any via lo0
${IPFW} add deny ip from any to 127.0.0.0/8
${IPFW} add deny ip from 127.0.0.0/8 to any

#То же с локалкой
${IPFW} add allow tcp from any to any via ${INT}
${IPFW} add allow udp from any to any via ${INT}
${IPFW} add allow icmp from any to any via ${INT}

#Дропаем всякие нереальные сети, мультикасты и иже с ними
${IPFW} add deny ip from any to 10.0.0.0/8 in via ${EXT}
${IPFW} add deny ip from any to 172.16.0.0/12 in via ${EXT}
${IPFW} add deny ip from any to 192.168.0.0/16 in via ${EXT}
${IPFW} add deny ip from any to 0.0.0.0/8 in via ${EXT}
${IPFW} add deny ip from any to 169.254.0.0/16 in via ${EXT}
${IPFW} add deny ip from any to 240.0.0.0/4 in via ${EXT}
${IPFW} add deny log icmp from any to 255.255.255.255 in via ${EXT}
${IPFW} add deny icmp from any to 255.255.255.255 out via ${EXT}
${IPFW} add deny log ip from 10.0.0.0/8 to any out via ${EXT}
${IPFW} add deny ip from 172.16.0.0/12 to any out via ${EXT}
${IPFW} add deny ip from 192.168.0.0/16 to any out via ${EXT}
${IPFW} add deny ip from 0.0.0.0/8 to any out via ${EXT}
${IPFW} add deny ip from 169.254.0.0/16 to any out via ${EXT}
${IPFW} add deny ip from 224.0.0.0/4 to any out via ${EXT}
${IPFW} add deny ip from 240.0.0.0/4 to any out via ${EXT}

#Дропаем фрагментированный пинг
${IPFW} add deny icmp from any to any frag

#Врубаем NAT
${IPFW} add divert natd ip from ${LAN}/${LAN_MSK} to any out via ${EXT}
${IPFW} add divert natd ip from any to ${EXT_IP} in via ${EXT}

#Не дропать установленные коннекты
${IPFW} add allow tcp from any to any established
#Асько))
${IPFW} add allow all from any to any 5190 via ${EXT}

#DNS
${IPFW} add allow udp from any 53 to any via ${EXT}
${IPFW} add allow udp from any to any 53 via ${EXT}
#Если нет бинда - грохай строчки
${IPFW} add allow tcp from any 53 to any via ${EXT}
${IPFW} add allow tcp from any to any 53 via ${EXT}

#Разрешаем NTP
#${IPFW} add allow udp from any to any 123 via ${EXT}
#Разрешаем пинги, etc.
${IPFW} add allow icmp from any to any icmptypes 0,8,11
#SSH
${IPFW} add allow log tcp from any to any 2022 in via ${EXT}

#VPN
#${IPFW} add allow udp from any to ${EXT_IP} 1194 in via ${EXT}
#${IPFW} add allow tcp from any to ${EXT_IP} 1194 in via ${EXT} setup
#${IPFW} add allow gre from any to any

#Разрешаем выход с внешнего ипа
#${IPFW} add allow log ip from ${EXT_IP} to any 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.192.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.112.96.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 195.38.160.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.26.220.0/22 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.2.224.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 81.20.16.0/20 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.42.96.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 77.95.56.0/21 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 94.143.192.0/21 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.241.0.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 213.145.128.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.113.0.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 89.237.192.0/18 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 77.235.0.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 92.245.96.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.152.36.0/24 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.152.37.0/24 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.205.48.0/22 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 95.215.244.0/22 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 217.29.16.0/20 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 81.88.192.0/20 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 92.62.64.0/20 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.97.0.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 109.201.160.0/19 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 193.106.48.0/22 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.213.233.0/24 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 109.71.224.0/21 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.176.111.0/24 80,443 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.192.64.0/22 80,443 out xmit ${EXT}

#Нах ибо нех
${IPFW} add deny log all from any to any
Я не злопамятный, я просто часто ковыряю логи
User avatar
Gen1us2k
Модератор
Модератор
Posts: 771
Joined: 02 Mar 2010, 16:13

Re: конвертирование конфига iptables в конфиг ipfw

Post by Gen1us2k » 04 Dec 2010, 08:25

пасиб, доковыряю уже сам
Image
Home: Windows Heaven
Home: Debian 6
For Servers: Debian || RHEL Based || Gentoo || FreeBSD
User avatar
Gen1us2k
Модератор
Модератор
Posts: 771
Joined: 02 Mar 2010, 16:13

Re: конвертирование конфига iptables в конфиг ipfw

Post by Gen1us2k » 11 Mar 2011, 14:42

не работает %)

Code: Select all

#!/bin/sh
IPFW="/sbin/ipfw"
SCTL="/sbin/sysctl"
EXT="bge0" #External interface
EXT_IP="212.112.*.*"

# Reduce waiting time for a SYN-ACK request
${SCTL} net.inet.tcp.msl=7500
# Convert server into a black hole (reduces the load on the server during DDoS-attack on random ports):
${SCTL} net.inet.tcp.blackhole=2
${SCTL} net.inet.udp.blackhole=1
# Limit the number of responses to the ICMP-messages of 50 on second.
${SCTL} net.inet.icmp.icmplim=50
# Increase the max number of connections to the server (some protection of all types of DDoS)
${SCTL} kern.ipc.somaxconn=32768
#Включай DEVICE_POLLING в ведре - существенно снизит нагрузку на систему во время DDoS
#Пересобирай ядро с опцией «options DEVICE_POLLING»
#Врубаешь: «sysctl kern.polling.enable=1» (можно вписать тремя строками выше) либо
#Добавь запись «kern.polling.enable=1» в /etc/sysctl.conf.

# Clean up
${IPFW} -f flush
${IPFW} -f pipe flush
${IPFW} -f queue flush

${IPFW} add check-state

# Allow lo do anything
${IPFW} add allow ip from any to any via lo0
${IPFW} add deny ip from any to 127.0.0.0/8
${IPFW} add deny ip from 127.0.0.0/8 to any

# Drop all unreal networks, multicasts
${IPFW} add deny ip from any to 10.0.0.0/8 in via ${EXT}
${IPFW} add deny ip from any to 172.16.0.0/12 in via ${EXT}
${IPFW} add deny ip from any to 192.168.0.0/16 in via ${EXT}
${IPFW} add deny ip from any to 0.0.0.0/8 in via ${EXT}
${IPFW} add deny ip from any to 169.254.0.0/16 in via ${EXT}
${IPFW} add deny ip from any to 240.0.0.0/4 in via ${EXT}
${IPFW} add deny log icmp from any to 255.255.255.255 in via ${EXT}
${IPFW} add deny icmp from any to 255.255.255.255 out via ${EXT}
${IPFW} add deny log ip from 10.0.0.0/8 to any out via ${EXT}
${IPFW} add deny ip from 172.16.0.0/12 to any out via ${EXT}
${IPFW} add deny ip from 192.168.0.0/16 to any out via ${EXT}
${IPFW} add deny ip from 0.0.0.0/8 to any out via ${EXT}
${IPFW} add deny ip from 169.254.0.0/16 to any out via ${EXT}
${IPFW} add deny ip from 224.0.0.0/4 to any out via ${EXT}
${IPFW} add deny ip from 240.0.0.0/4 to any out via ${EXT}

# Drop fragmented ping 
${IPFW} add deny icmp from any to any frag

# DO NOT Drop ESTABLISHED connections
${IPFW} add allow tcp from any to any established
# DNS
${IPFW} add allow udp from any 53 to any via ${EXT}
${IPFW} add allow udp from any to any 53 via ${EXT}

# Allow NTP
${IPFW} add allow udp from any to any 123 via ${EXT}
# Allow ICMP
${IPFW} add allow icmp from any to any icmptypes 0,8,11
# SSH
${IPFW} add allow log tcp from any to any 22 in via ${EXT}

# Allow incoming connections 
#${IPFW} add allow log ip from ${EXT_IP} to any 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 89.237.192.0/18 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 80.72.176.0/20 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 81.20.16.0/20 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.193.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.152.37.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.112.96.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.200.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.195.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 92.245.96.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 92.62.64.0/20 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.216.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 77.95.56.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.97.0.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.2.224.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.205.48.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 109.201.160.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 81.88.192.0/20 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 193.106.48.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 94.143.192.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 217.29.16.0/20 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.241.0.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.213.233.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.113.0.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.196.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 195.38.160.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 109.71.224.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 178.217.168.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 212.42.96.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.176.111.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.192.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 178.216.208.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.199.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.198.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 77.235.0.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 194.152.36.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 95.215.244.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.26.220.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.194.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 195.162.92.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 91.192.64.0/22 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.197.0/24 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 85.115.208.0/21 80,443,8085,8086,10000,3724 out xmit ${EXT}
${IPFW} add allow ip from ${EXT_IP} to 213.145.128.0/19 80,443,8085,8086,10000,3724 out xmit ${EXT}


# Fuck all
${IPFW} add deny log all from any to any
Image
Home: Windows Heaven
Home: Debian 6
For Servers: Debian || RHEL Based || Gentoo || FreeBSD
User avatar
Raven
Бородатый сис
Бородатый сис
Posts: 2794
Joined: 03 Mar 2010, 15:12
ОС: RHEL 8
Location: Из серверной

Re: конвертирование конфига iptables в конфиг ipfw

Post by Raven » 11 Mar 2011, 15:34

Gen1us2k wrote:# SSH
${IPFW} add allow log tcp from any to any 22 in via ${EXT}
После этого поставь строчку

Code: Select all

${IPFW} add allow log tcp from any to any 80 in recv ${EXT}
Если хочешь иметь доступ к веб-серверу
Я не злопамятный, я просто часто ковыряю логи
User avatar
Gen1us2k
Модератор
Модератор
Posts: 771
Joined: 02 Mar 2010, 16:13

Re: конвертирование конфига iptables в конфиг ipfw

Post by Gen1us2k » 11 Mar 2011, 21:05

угу. все нящно. не работало, потому что не под скрином запускал по ссх, да и тачку ребутнули не правильно
Image
Home: Windows Heaven
Home: Debian 6
For Servers: Debian || RHEL Based || Gentoo || FreeBSD
Post Reply