/etc/init.d/iptablesconf: line 135: -A: comand not found
line 135 - для примера. Везде, где происходит добавление через -А такая ошибка.
т.е. почему-то не распознает команду добавления правила в цепочку..
Никто не сталкивался?
/etc/init.d/iptablesconf: line 135: -A: comand not found
line 135 - для примера. Везде, где происходит добавление через -А такая ошибка.
т.е. почему-то не распознает команду добавления правила в цепочку..
Никто не сталкивался?
Дистрибутив - Mandriva 2007 spring
Может хоть текст скрипта покажете? Оформлять в теге CODEBOX
/etc/init.d/iptablesconf: line 135: -A: comand not found
line 135 - для примера. Везде, где происходит добавление через -А такая ошибка.
т.е. почему-то не распознает команду добавления правила в цепочку..
Никто не сталкивался?
Дистрибутив - Mandriva 2007 spring
Может хоть текст скрипта покажете? Оформлять в теге CODEBOX
не вопрос )
Код:
#cat main.rules.iptables
****************main.rules.iptables****************
#!/bin/sh
iptables --flush
iptables -t nat --flush
clear
###########################################################################
#
# 1. Configuration options.
#
#
# 1.1 Internet Configuration.
#
INET_IP="10.10.12.33"
INET_IFACE="rl1"
#
# 1.2 Local Area Network configuration.
#
#
LAN_IP="192.168.0.100"
LAN_IP_RANGE="192.168.0.0/24"
LAN_IFACE="rl0"
# 1.4 Localhost Configuration.
#
LO_IFACE="lo"
LO_IP="127.0.0.1"
#
# 1.5 IPTables Configuration.
IPTABLES="iptables"
###########################################################################
#
# 2. Module loading.
#
/sbin/depmod -a
#
# 2.1 Required modules
#
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
#/sbin/modprobe ipt_LOG
#/sbin/modprobe ipt_limit
/sbin/modprobe ipt_state
#
# 2.2 Non-Required modules
#
#/sbin/modprobe ipt_owner
#/sbin/modprobe ipt_REJECT
#/sbin/modprobe ipt_MASQUERADE
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_conntrack_irc
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_nat_irc
###########################################################################
#
# 3. /proc set up.
#
#
# 3.1 Required proc configuration
#
echo "1" > /proc/sys/net/ipv4/ip_forward
#
# 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
#
$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
#
$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 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 192.168.0.75 --dport 21 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.97 --dport 21 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.0 --dport 21 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 21 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.75 --dport 22 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.97 --dport 22 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.0 --dport 22 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 22 -j allowed
#$IPTABLES -A tcp_packets -p TCP -s 192.168.0.75 --dport 25 -j ACCEPT
#$IPTABLES -A tcp_packets -p TCP -s 192.168.0.97 --dport 25 -j ACCEPT
#$IPTABLES -A tcp_packets -p TCP -s 192.168.0.0 --dport 25 -j DROP
#$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 25 -j allowed
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.75 --dport 80 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.97 --dport 80 -j ACCEPT
$IPTABLES -A tcp_packets -p TCP -s 192.168.0.0 --dport 80 -j DROP
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 80 -j allowed
#
# UDP ports
#
#$IPTABLES -A udp_packets -p UDP -s 0/0 --destination-port 53 -j ACCEPT
#
# 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
#
$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 192.168.0.75 -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LAN_IFACE -s 192.168.0.97 -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LO_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $LAN_IP -j ACCEPT
$IPTABLES -A INPUT -p ALL -i $LO_IFACE -s $INET_IP -j ACCEPT
#
# Rules for incoming packets from the internet.
#
$IPTABLES -A INPUT -p ALL -d $INET_IP -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p TCP -i $INET_IFACE -j tcp_packets
$IPTABLES -A INPUT -p UDP -i $INET_IFACE -j udp_packets
$IPTABLES -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets
#
# 4.1.5 FORWARD chain
#
$IPTABLES -A FORWARD -p tcp -j bad_tcp_packets
#
# Accept the packets we actually want to forward
#
$IPTABLES -A FORWARD -s 192.168.0.75 -d 239.255.2.0/255.255.255.240 -p udp --dport 1234 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -d 239.255.2.0/255.255.255.240 -p udp --dport 1234 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.75 -p tcp --sport 50005 -p tcp --dport 50005 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.75 -p udp --sport 50005 -p udp --dport 50005 -j ACCEPT
$IPTABLES -A FORWARD -d 192.168.0.75 -p tcp --dport 50005 -i $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -d 192.168.0.75 -p udp --dport 50005 -i $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -p tcp --sport 50003 -d 0/0 -p tcp --dport 50003 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -p udp --sport 50003 -d 0/0 -p udp --dport 50003 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -p tcp --sport 29798 -d 0/0 -p tcp --dport 29798 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -p udp --sport 29798 -d 0/0 -p udp --dport 29798 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.75 -i $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.0.97 -i $INET_IFACE -j ACCEPT
$IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#
# 4.1.6 OUTPUT chain
#
$IPTABLES -A OUTPUT -p tcp -j bad_tcp_packets
#
# Special OUTPUT rules to decide which IP's to allow.
#
$IPTABLES -A OUTPUT -p ALL -s $LO_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $LAN_IP -j ACCEPT
$IPTABLES -A OUTPUT -p ALL -s $INET_IP -j ACCEPT
#
# Enable simple IP Forwarding and Network Address Translation
#
$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP