|
发表于 2003-10-1 12:58:21
|
显示全部楼层
在CU上有一个,你看看,根据自己的实践适当修改修改!
脚本firewall如下: - #! /bin/sh
- IPTABLES=/sbin/iptables
- EXTERNAL="eth0"
- INTERNAL="eth1"
- IP=10.36.6.0.0/255.255.0.0
- $IPTABLES -P INPUT ACCEPT
- $IPTABLES -P FORWARD ACCEPT
- $IPTABLES -P OUTPUT ACCEPT
- $IPTABLES -t nat -P PREROUTING ACCEPT
- $IPTABLES -t nat -P POSTROUTING ACCEPT
- $IPTABLES -t nat -P OUTPUT ACCEPT
- $IPTABLES -F
- $IPTABLES -t nat -F
- $IPTABLES -X
- $IPTABLES -t nat -X
- start() {
- echo -n $"Starting firewall "
- # Enable IPV4 Packet Forwarding
- echo 1 > /proc/sys/net/ipv4/ip_forward
- for i in /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/*
- do
- t=`echo $i |sed 's/\.o$//g'`
- module=`basename $t`
- modprobe $module
- done
- #
- #允许ICMP数据包(ping)
- $IPTABLES -A INPUT -p icmp -j ACCEPT
- #允许内部网之间的数据通讯
- $IPTABLES -A INPUT -i $INTERNAL -s $PRINET -j ACCEPT
- $IPTABLES -A OUTPUT -o $INTERNAL -d $PRINET -j ACCEPT
- echo "Input and output Sucess"
- $IPTABLES -t nat -A POSTROUTING -o $EXTERNAL -j MASQUERADE
- echo_success
- }
- stop(){
- echo -n $"Stopping Firewall"
- flush
- for i in /lib/modules/`uname -r`/kernel/net/ipv4/netfilter/*
- do
- t=`echo $i |sed 's/\.o$//g'`
- module=`basename $t`
- modprobe -r $module
- done
- # Disale IPV4 Packet Forwarding
- echo "0" > /proc/sys/net/ipv4/ip_forward
- echo_success
- }
- restart()
- {
- stop
- start
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- exit 1
- esac
复制代码 |
|