2 # Filename: grml-router
3 # Purpose: set up your box as NAT-router
4 # Authors: grml-team (grml.org), Ulrich Dangel <schula@grml.org>, Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Sam Okt 07 23:18:38 CEST 2006 [mika]
8 ################################################################################
13 CONFIG_FILE=/etc/grml/routersetup
14 . /etc/grml/lsb-functions
15 . /etc/grml/net-functions
16 . /etc/grml/script-functions
18 if [ $UID != 0 ]; then
19 eerror "Error: become root before starting $0"
23 if ! [ -r $CONFIG_FILE ] ; then
24 eerror "$CONFIG_FILE could not be read."
30 if [ -z "$OUTDEV" ] ; then
31 eerror "Outgouing device is not set in $CONFIG_FILE"
37 OUTDEV=$(defaultGWDev)
41 [ -n "$IPTABLES" ] || IPTABLES=/sbin/iptables
43 check4progs $IPTABLES || exit 1
47 einfo "Adjusting kernel variables (net.ipv4.*)"
48 sysctl -w net.ipv4.conf.all.rp_filter=1 1>/dev/null && \
49 sysctl -w net.ipv4.conf.all.log_martians=1 1>/dev/null && \
50 sysctl -w net.ipv4.ip_forward=1 1>/dev/null
52 einfo "Setting up iptables rule"
55 einfo "Adding masquarade rule"
56 $IPTABLES -t nat -A POSTROUTING -o $OUTDEV -j MASQUERADE
62 einfo "Resetting kernel variables"
63 sysctl -w net.ipv4.ip_forward=0 1>/dev/null && \
64 sysctl -w net.ipv4.conf.all.log_martians=0 1>/dev/null
67 einfo "Removing iptables rule"
68 $IPTABLES -t nat -D POSTROUTING -o $OUTDEV -j MASQUERADE
79 einfo "$0 - script which turns on router capabilities (NAT)"
80 einfo "Configure it via $CONFIG_FILE" ; eend 0
84 echo "Usage: $0 {start|stop|restart|info}"
89 ## END OF FILE #################################################################
90 # vim: ft=sh expandtab ai