iptables 做网关

#!/bin/bash
START() {
echo "NAT is start...."
echo "1" > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT --to-source 10.0.0.0.1
}
STOP() {
echo "NAT is stop..."
echo "0" >/proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -F
}
STATUS() {
/sbin/iptables -t nat -L POSTROUTING
}
case $1 in
start)
START
;;
stop)
STOP
;;
status)
STATUS
;;
restart)
STOP
START
echo "NAT is restart..."
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
~

你可能感兴趣的:(iptables)