# 3.2 Non-Required proc configuration

#

#echo '1' > /proc/sys/net/ipv4/conf/all/rp_filter

#echo '1' > /proc/sys/net/ipv4/conf/all/proxy_arp

#echo '1' > /proc/sys/net/ipv4/ip_dynaddr

################################################################## #########

#

# 4. rules set up.

#

######

# 4.1 Filter table

#

#

# 4.1.1 Set policies

#

$IPTABLES -P INPUT DROP

$IPTABLES -P OUTPUT DROP

$IPTABLES -P FORWARD DROP

#

# 4.1.2 Create userspecified chains

#

#

# Create chain for bad tcp packets

#

$IPTABLES -N bad_tcp_packets

#

# Create separate chains for ICMP, TCP and UDP to traverse

#

$IPTABLES -N allowed

$IPTABLES -N tcp_packets

$IPTABLES -N udp_packets

$IPTABLES -N icmp_packets

#

# 4.1.3 Create content in userspecified chains

#

#

# bad_tcp_packets chain

#

$IPTABLES -A bad_tcp_packets -p tcp –tcp-flags SYN,ACK SYN,ACK

–m state –state NEW -j REJECT –reject-with tcp-reset

$IPTABLES -A bad_tcp_packets -p tcp ! –syn -m state –state NEW -j LOG

–log-prefix «New not syn:»

$IPTABLES -A bad_tcp_packets -p tcp ! –syn -m state –state NEW -j DROP

#

# allowed chain

#

$IPTABLES -A allowed -p TCP –syn -j ACCEPT

$IPTABLES -A allowed -p TCP -m state –state ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -A allowed -p TCP -j DROP

#

# TCP rules

#

$IPTABLES -A tcp_packets -p TCP -s 0/0 –dport 21 -j allowed

$IPTABLES -A tcp_packets -p TCP -s 0/0 –dport 22 -j allowed

$IPTABLES -A tcp_packets -p TCP -s 0/0 –dport 80 -j allowed

$IPTABLES -A tcp_packets -p TCP -s 0/0 –dport 113 -j allowed

#

# UDP ports

#

$IPTABLES -A udp_packets -p UDP -s 0/0 –source-port 53 -j ACCEPT

if [ $DHCP == «yes» ] ; then

$IPTABLES -A udp_packets -p UDP -s $DHCP_SERVER –sport 67

–dport 68 -j ACCEPT

fi

#$IPTABLES -A udp_packets -p UDP -s 0/0 –source-port 53 -j ACCEPT

#$IPTABLES -A udp_packets -p UDP -s 0/0 –source-port 123 -j ACCEPT

$IPTABLES -A udp_packets -p UDP -s 0/0 –source-port 2074 -j ACCEPT

$IPTABLES -A udp_packets -p UDP -s 0/0 –source-port 4000 -j ACCEPT

#

# In Microsoft Networks you will be swamped by broadcasts. These lines

# will prevent them from showing up in the logs.

#

#$IPTABLES -A udp_packets -p UDP -i $INET_IFACE

#–destination-port 135:139 -j DROP

#

# If we get DHCP requests from the Outside of our network, our logs will

# be swamped as well. This rule will block them from getting logged.

#

#$IPTABLES -A udp_packets -p UDP -i $INET_IFACE -d 255.255.255.255

#–destination-port 67:68 -j DROP

#

# ICMP rules

#

$IPTABLES -A icmp_packets -p ICMP -s 0/0 –icmp-type 8 -j ACCEPT

$IPTABLES -A icmp_packets -p ICMP -s 0/0 –icmp-type 11 -j ACCEPT

#

# 4.1.4 INPUT chain

#

#

# Bad TCP packets we don't want.

#

$IPTABLES -A INPUT -p tcp -j bad_tcp_packets

#

# Rules for special networks not part of the Internet

#

$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -s $LAN_IP_RANGE -j ACCEPT

$IPTABLES -A INPUT -p ALL -i $LO_IFACE -j ACCEPT

Вы читаете Iptables Tutorial 1.1.19
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату