Create a script /etc/init.d/gateway
#! /bin/sh
# If no rules, do nothing.
[ -f /etc/gateway.rules ] || exit 0
case "$1" in
start)
echo -n "Turning on packet filtering:"
/sbin/modprobe ip_masq_ftp #only if using ipchains
/sbin/modprobe iptable_nat #only if using iptables
/sbin/modprobe ipt_MASQUERADE #only if using iptables
/sbin/ipchains-restore < /etc/ipchains.rules || exit 1
echo 1 > /proc/sys/net/ipv4/ip_forward
# for RedHat users, the above line is not needed if you have
# FORWARD_IPV4=true in /etc/sysconfig/network file
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
# the above option is for Dynamic IP users (DHCP,PPP or BOOTP)
echo "."
;;
stop)
echo -n "Turning off packet filtering:"
echo 0 > /proc/sys/net/ipv4/ip_forward
/sbin/ipchains -F
/sbin/ipchains -X
/sbin/ipchains -P input ACCEPT
/sbin/ipchains -P output ACCEPT
/sbin/ipchains -P forward ACCEPT
echo "."
;;
*)
echo "Usage: /etc/init.d/gateway {start|stop}"
exit 1
;;
esac
exit 0 |
Give execute permissions to the startup scripts
bash# chmod 744 /etc/init.d/gateway |
Use rcconf or chkconfig to create startup links for this file.