IP masquerading - start/stop script

Support knowledgebase (firewall)
Applicable to
S.u.S.E. version: from 4.4 on

Question:

How does one do IP masquerading?

Answer:

One could write a lot about that topic....

Before you click on the following link, please check, whether the howto package howto, serie doc is installed on your local system. This link refers to a howto file in your local system.

Details about the topic "firewalling" are in Firewall-HOWTO

Here a short start/stop script. Replace the variable MQ_LOCALNET correspondingly. Please save the script as

/sbin/init.d/firewall
#! /bin/sh
# Copyright (c) 1996 S.u.S.E. Gmbh Fuerth, Germany.  All rights reserved.
#
# Author: Bodo Bauer 
#   
#
#
# /sbin/init.d/firewall
#

IPFWADM="/sbin/ipfwadm"

# local net
MQ_LOCALNET="192.168.0.0/255.255.255.0"

echo -n "Setting up firewall/masquerading "

##  first of all close everything
for i in -I -O -F; do
  # clear all rules
  ${IPFWADM} $i -f
  # make deny default
  ${IPFWADM} $i -p deny
done

case "$1" in
    start)
        echo "(start)"
        ${IPFWADM} -F -a accept -P all -S 0/0 -D ${MQ_LOCALNET} -b -m
        ;;

    stop)
        echo "(stop)"
        for i in -I -O -F; do
          # make accept default 
          ${IPFWADM} $i -p accept
        done
        ;;
    *)
        echo ""
        echo "Usage: $0 {start|stop}"
        for i in -I -O -F; do
          # make accept default 
          ${IPFWADM} $i -p accept
        done
        exit 1
esac

## NOTE: we mainly 'deny' per ports (see above),
## so, as we have now set up the rules correctly,
## open all filters
for i in -I -O -F; do
  ${IPFWADM} $i -p accept
done

## list the rules
for i in -O -F -I; do
 ${IPFWADM} $i -ln
done

exit 0

Bugs:


Keywords: FIREWALL, IPFWADM, MASQUERADING, TCPIP, NETWORK, NET, SECURITY

Feedback welcome: Send Mail to kfr@suse.de (Please give the following subject: SDB-firewall)
SDB-firewall, Copyright SuSE Linux AG, Nürnberg, Germany - Version: 23. Jul 2002 13:23:14
SuSE Linux AG - Last generated: 23. Jul 2002 13:23:14 by kfr (sdb_gen 1.40.0)