如何运行iptables脚本

由 zhangxin_tmx 在 08-30-2004 12:30 发表:

如何运行iptables脚本

我的系统是Redhat 9.0,我从别处移植了一个iptables脚本,但运行时总提示:

[root@Test-Proxt root]#./setiptables

-bash: ./setiptables: 没有那个文件或目录

这个脚本在7.0系统上可以运行,请问是什么原因?如何处理?

附上脚本内容:

#!/bin/sh

configuration options

LAN_IP_RANGE="192.169.10.0/24"

LAN_IP="192.169.10.1"

LAN_BCAST_ADRESS="192.169.10.255"

LAN_IFACE="eth1"

INET_IP="202.111.44.199"

INET_IFACE="eth0"

LO_IP="127.0.0.1"

LO_IFACE="127.0.0.1"

IPTABLES="/sbin/iptables"

#echo "Starting iptables rules..."

Load all required IPTables modules

Needed to initially load modules

/sbin/depmod -a

Adds some iptables targets like LOG, REJECT and MASQUARADE.

/sbin/modprobe ipt_LOG

/sbin/modprobe ipt_MASQUERADE

/sbin/modprobe ip_tables

/sbin/modprobe ip_nat_ftp

/sbin/modprobe ip_conntrack_ftp

Delete old PREROUTING chain

$IPTABLES -t nat -F PREROUTING

#------------------------------------------------------------------------------

$IPTABLES -t nat -A PREROUTING -s 192.168.0.0/16 -j DROP

$IPTABLES -t nat -A PREROUTING -s 10.0.0.0/8 -j DROP

$IPTABLES -t nat -A PREROUTING -s 172.16.0.0/12 -j DROP

#------------------------------------------------------------------------------

Delete old POSTROUTING chain

$IPTABLES -t nat -F POSTROUTING

MASQ to INET_IFACE

$IPTABLES -t nat -A POSTROUTING -o $INET_IFACE -j MASQUERADE

set SNAT

$IPTABLES -t nat -A POSTROUTING -s $LAN_IP_RANGE -j SNAT --to $INET_IP

Delete old INPUT chain

$IPTABLES -F INPUT

Drop ports in PREROUTING

#$IPTABLES -A INPUT -p tcp -i $INET_IFACE -d $INET_IP --dport 10021 -j RETURN

port:22

$IPTABLES -A INPUT -p tcp -i $INET_IFACE -s 202.111.44.200/32 -d $INET_IP --dport 22 -j ACCEPT

$IPTABLES -A INPUT -p tcp --dport 22 -j DROP<b

Published At
Categories with 服务器类
Tagged with
comments powered by Disqus