#!/bin/tcsh ##################################################### #### #### #### IpTables - MASQURAG fuer Hosts in der DMZ #### #### TestSeqment #### #### #### ##################################################### #### #### #### Autor: Uli Fietz #### #### 2011-04-06 #### ##################################################### ##################### #### Variablen #### ##################### # #### Ports #### # set iptables = /sbin/iptables set p_high = 1024:65535 # unprivilileged ports set p_low = 1:1023 # Admin-Ports # # #---------------------------------------------------- # #### Interfaces #### # set EXT = eth0 set DMZ = eth1 #---------------------------------------------------- # ############################################## #### Dynamische Kernel-Parameter setzen #### ############################################## #-- Interface unabhaengig -- # echo "0" > /proc/sys/net/ipv4/ip_forward # Forward abschalten echo "1" > /proc/sys/net/ipv4/tcp_syncookies echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts echo "1" > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses # #-- Interface abhaengig -- # #-------- eth0 ------------- echo "1" > /proc/sys/net/ipv4/conf/eth0/rp_filter echo "0" > /proc/sys/net/ipv4/conf/eth0/accept_redirects echo "0" > /proc/sys/net/ipv4/conf/eth0/accept_source_route echo "0" > /proc/sys/net/ipv4/conf/eth0/bootp_relay echo "1" > /proc/sys/net/ipv4/conf/eth0/log_martians # #-------- eth1 ------------- echo "1" > /proc/sys/net/ipv4/conf/eth1/rp_filter echo "0" > /proc/sys/net/ipv4/conf/eth1/accept_redirects echo "0" > /proc/sys/net/ipv4/conf/eth1/accept_source_route echo "0" > /proc/sys/net/ipv4/conf/eth1/bootp_relay echo "1" > /proc/sys/net/ipv4/conf/eth1/log_martians # #-------- alte Regeln loeschen ------------ # $iptables -F # Loeschen aller Chains - filter - $iptables -t nat -F # Loeschen aller Chains - nat - $iptables -X # Loeschen aller benutzerdef. Chains - filter - #---------------------------------------------------------------------- # echo "1" > /proc/sys/net/ipv4/ip_forward # Forward einschalten # ################################################### #### Default Policy und alte Regeln Loeschen #### ################################################### # #-------- Policy ----------- # $iptables -P INPUT ACCEPT $iptables -P FORWARD ACCEPT $iptables -P OUTPUT ACCEPT #--------------------------- # #---- lokales Interface - localhost zulassen ---------- # $iptables -A OUTPUT -o lo -j ACCEPT $iptables -A INPUT -i lo -j ACCEPT # #################################### # Masquerading # #################################### # $iptables -t nat -A POSTROUTING -o $EXT -j MASQUERADE