I have Mandrake 9.1 and am running ez-ipupdate. The problem I'm
running into is that when the IP address changes, IPTables seems to
block traffic from ez-ipupdate. If I do a:
/etc/rc.d/init.d/network restart
/etc/rc.d/init.d/rc.firewall restart
killall -HUP ez-ipupdate
Everything works until the ip address changes again.
Here's my rc.firewall:
=========================================================================== #!/bin/sh # This is the location of the iptables command case "$1" in $IPTABLES -P INPUT ACCEPT ##--------------------------Begin #----Default-Interfaces-----# ## Default external interface (used, if EXTIF isn't specified on ## Default internal interface (used, if INTIF isn't specified on #----Special Variables-----# # IP Mask for all IP addresses # Specification of the high unprivileged IP ports. # Specification of X Window System (TCP) ports. # Ports for IRC-Connection-Tracking #-----Port-Forwarding Variables-----# #For port-forwarding to an internal host, define a variable with the #These are examples, uncomment to activate #IP for forwarded Battlecom-traffic #IP for forwarded HTTP-traffic #----Flood Variables-----# # Overall Limit for TCP-SYN-Flood detection # Overall Limit for Loggging in Logging-Chains # Overall Limit for Ping-Flood-Detection #----Automatically determine infos about involved interfaces-----# ### External Interface: ## Get external interface from command-line ## Determine external IP ## Determine external gateway echo " --- " ### Internal Interface: ## Get internal interface from command-line ## Determine internal IP ## Determine internal netmask ## Determine network address of the internal network echo "" #----Load IPTABLES-modules-----# #Insert modules- should be done automatically if needed #If the IRC-modules are available, uncomment them below echo "Loading IPTABLES modules" dmesg -n 1 #Kill copyright display on module load echo " --- " #----Clear/Reset all chains-----# #Clear all IPTABLES-chains #Flush everything, start from scratch #Set default policies to DROP #----Set network sysctl options-----# echo "Setting sysctl options" #Enable forwarding in kernel #Disabling IP Spoofing attacks. #Don't respond to broadcast pings (Smurf-Amplifier-Protection) #Block source routing #Kill timestamps #Enable SYN Cookies #Kill redirects #Enable bad error message protection #Log martians (packets with impossible addresses) #Set out local port range #Reduce DoS'ing ability by reducing timeouts echo " --- " echo "Creating user-chains" #----Create logging chains-----# ##These are the logging-chains. They all have a certain limit of #Invalid packets (not ESTABLISHED,RELATED or NEW) #TCP-Packets with one ore more bad flags #Logging of connection attempts on special ports (Trojan portscans, #Logging of possible TCP-SYN-Floods #Logging of possible Ping-Floods #All other dropped packets #All other rejected packets #----Create Accept-Chains-----# #TCPACCEPT - Check for SYN-Floods before letting TCP-Packets in $IPTABLES -N TCPACCEPT #----Create special User-Chains-----# #CHECKBADFLAG - Kill any Inbound/Outbound TCP-Packets with impossible $IPTABLES -N CHECKBADFLAG #FILTERING FOR SPECIAL PORTS #Inbound/Outbound SILENTDROPS/REJECTS (Things we don't want in our #SMB-Traffic $IPTABLES -A SMB -p tcp --dport 137 -j DROP read more »
IPTABLES="/sbin/iptables"
stop)
echo "Shutting down firewall..."
$IPTABLES -F
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -X -t mangle
$IPTABLES -X -t nat
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
echo "...done"
;;
status)
echo $"Table: filter"
iptables --list
echo $"Table: nat"
iptables -t nat --list
echo $"Table: mangle"
iptables -t mangle --list
;;
restart|reload)
$0 stop
$0 start
;;
start)
echo "Starting Firewall..."
echo ""
Firewall---------------------------------##
command line)
DEFAULT_EXTIF="eth0"
IP=` /sbin/ifconfig $EXTIF | grep 'inet addr' | awk '{print $2}' | sed
-e s/.*://`
command line)
DEFAULT_INTIF="eth1"
UNIVERSE="0.0.0.0/0"
UNPRIVPORTS="1024:65535"
XWINPORTS="6000:6063"
IRCPORTS="6665,6666,6667,6668,6669,7000"
appropriate
#internal IP-Address here and take a look at the port-forwarding
sections in the FORWARD +
#PREROUTING-chain:
#BATTLECOMIP="192.168.0.5"
#HTTPIP="192.168.0.20"
TCPSYNLIMIT="5/s"
# Burst Limit for TCP-SYN-Flood detection
TCPSYNLIMITBURST="10"
LOGLIMIT="2/s"
# Burst Limit for Logging in Logging-Chains
LOGLIMITBURST="10"
PINGLIMIT="5/s"
# Burst Limit for Ping-Flood-Detection
PINGLIMITBURST="10"
## If no interface is specified then set $DEFAULT_EXTIF as EXTIF
#if [ "x$2" != "x" ]; then
# EXTIF=$2
#else
EXTIF=$DEFAULT_EXTIF
#fi
echo External Interface: $EXTIF
EXTIP="`ifconfig $EXTIF | grep inet | cut -d : -f 2 | cut -d \ -f 1`"
if [ "$EXTIP" = '' ]; then
echo "Aborting: Unable to determine the IP-address of $EXTIF !"
exit 1
fi
echo External IP: $EXTIP
EXTGW=`route -n | grep -A 4 UG | awk '{ print $2}'`
echo Default GW: $EXTGW
## If no interface is specified then set $DEFAULT_INTIF as INTIF
if [ "x$3" != "x" ]; then
INTIF=$3
else
INTIF=$DEFAULT_INTIF
fi
echo Internal Interface: $INTIF
INTIP="`ifconfig $INTIF | grep inet | cut -d : -f 2 | cut -d \ -f 1`"
if [ "$INTIP" = '' ]; then
echo "Aborting: Unable to determine the IP-address of $INTIF !"
exit 1
fi
echo Internal IP: $INTIP
INTMASK="`ifconfig $INTIF | grep Mask | cut -d : -f 4`"
echo Internal Netmask: $INTMASK
INTLAN=$INTIP'/'$INTMASK
echo Internal LAN: $INTLAN
/sbin/modprobe ip_tables
/sbin/modprobe iptable_filter
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
#/sbin/modprobe ip_conntrack_irc ports=$IRCPORTS
#/sbin/modprobe ip_nat_irc ports=$IRCPORTS
dmesg -n 6
$IPTABLES -F
$IPTABLES -F -t mangle
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -X -t mangle
$IPTABLES -X -t nat
$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 2 > /proc/sys/net/ipv4/conf/all/rp_filter
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
echo 0 > /proc/sys/net/ipv4/tcp_timestamps
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects
echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses
echo 1 > /proc/sys/net/ipv4/conf/all/log_martians
echo "32768 61000" > /proc/sys/net/ipv4/ip_local_port_range
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 2400 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
echo 0 > /proc/sys/net/ipv4/tcp_sack
log-entries/sec to prevent log-flooding
##The syslog-entries will be fireparse-compatible (see
http://www.fireparse.com)
$IPTABLES -N LINVALID
$IPTABLES -A LINVALID -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=INVALID:1 a=DROP "
$IPTABLES -A LINVALID -j DROP
$IPTABLES -N LBADFLAG
$IPTABLES -A LBADFLAG -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=BADFLAG:1 a=DROP "
$IPTABLES -A LBADFLAG -j DROP
special services, etc.)
$IPTABLES -N LSPECIALPORT
$IPTABLES -A LSPECIALPORT -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=SPECIALPORT:1 a=DROP "
$IPTABLES -A LSPECIALPORT -j DROP
$IPTABLES -N LSYNFLOOD
$IPTABLES -A LSYNFLOOD -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=SYNFLOOD:1 a=DROP "
$IPTABLES -A LSYNFLOOD -j DROP
$IPTABLES -N LPINGFLOOD
$IPTABLES -A LPINGFLOOD -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=PINGFLOOD:1 a=DROP "
$IPTABLES -A LPINGFLOOD -j DROP
$IPTABLES -N LDROP
$IPTABLES -A LDROP -p tcp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=TCP:1 a=DROP "
$IPTABLES -A LDROP -p udp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=UDP:2 a=DROP "
$IPTABLES -A LDROP -p icmp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=ICMP:3 a=DROP "
$IPTABLES -A LDROP -f -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=FRAGMENT:4 a=DROP "
$IPTABLES -A LDROP -j DROP
$IPTABLES -N LREJECT
$IPTABLES -A LREJECT -p tcp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=TCP:1 a=REJECT "
$IPTABLES -A LREJECT -p udp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=UDP:2 a=REJECT "
$IPTABLES -A LREJECT -p icmp -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=ICMP:3 a=REJECT "
$IPTABLES -A LREJECT -f -m limit --limit $LOGLIMIT --limit-burst
$LOGLIMITBURST -j LOG --log-prefix "fp=FRAGMENT:4 a=REJECT "
$IPTABLES -A LREJECT -p tcp -j REJECT --reject-with tcp-reset
$IPTABLES -A LREJECT -p udp -j REJECT --reject-with
icmp-port-unreachable
$IPTABLES -A LREJECT -j REJECT
$IPTABLES -A TCPACCEPT -p tcp --syn -m limit --limit $TCPSYNLIMIT
--limit-burst $TCPSYNLIMITBURST -j ACCEPT
$IPTABLES -A TCPACCEPT -p tcp --syn -j LSYNFLOOD
$IPTABLES -A TCPACCEPT -p tcp ! --syn -j ACCEPT
flag-combinations (Some port-scanners use these, eg. nmap
Xmas,Null,etc.-scan)
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags ALL FIN,URG,PSH -j
LBADFLAG
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG
-j LBADFLAG
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags ALL ALL -j LBADFLAG
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags ALL NONE -j LBADFLAG
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags SYN,RST SYN,RST -j
LBADFLAG
$IPTABLES -A CHECKBADFLAG -p tcp --tcp-flags SYN,FIN SYN,FIN -j
LBADFLAG
Logs)
$IPTABLES -N SMB
$IPTABLES -A SMB -p tcp --dport 138 -j DROP
$IPTABLES -A SMB -p tcp --dport 139 -j DROP
$IPTABLES
...