
#!/bin/bash
## Iptables example ruleset
## ============================================================
#
# Load appropriate modules.
modprobe
modprobe
modprobe
modprobe ip_tables
ip_tables
ip_tables
ip_tables
modprobe
modprobe
modprobe
modprobe ip_conntrack
ip_conntrack
ip_conntrack
ip_conntrack
modprobe
modprobe
modprobe
modprobe ip_conntrack_ftp
ip_conntrack_ftp
ip_conntrack_ftp
ip_conntrack_ftp
# These lines are here in case rules are already in place and the script is ever rerun on the fly.
#
We
want to remove all rules and pre-exisiting user defined chains and zero the counters
# before we implement new rules.
iptables
iptables
iptables
iptables -F
-F
-F
-F
iptables
iptables
iptables
iptables -X
-X
-X
-X
iptables
iptables
iptables
iptables -Z
-Z
-Z
-Z
# Set up a default DROP policy for the built-in chains.
# If we modify and re-run the script mid-session then (because we have a default DROP
# policy), what happens is that there is a small time period when packets are denied until
# the new rules are back in place. There is no period, however small, when packets we
# don't want are allowed.
iptables
iptables
iptables
iptables -P
-P
-P
-P INPUT
INPUT
INPUT
INPUT DROP
DROP
DROP
DROP
iptables
iptables
iptables
iptables -P
-P
-P
-P FORW ARD
FORW ARD
FORW ARD
FORW ARD DROP
DROP
DROP
DROP
iptables
iptables
iptables
iptables -P
-P
-P
-P OUTPUT
OUTPUT
OUTPUT
OUTPUT DROP
DROP
DROP
DROP
## ===========================================================
## Some definitions:
IFACE="eth0,ppp0
IFACE="eth0,ppp0
IFACE="eth0,ppp0
IFACE="eth0,ppp0 ......
......
......
...... as
as
as
as appropriate"
appropriate"
appropriate"
appropriate"
IPADDR="your_ip_address_here"
IPADDR="your_ip_address_here"
IPADDR="your_ip_address_here"
IPADDR="your_ip_address_here"
NAMESERVER_1="x.x.x.x"
NAMESERVER_1="x.x.x.x"
NAMESERVER_1="x.x.x.x"
NAMESERVER_1="x.x.x.x"
NAMESERVER_2="x.x.x.x"
NAMESERVER_2="x.x.x.x"
NAMESERVER_2="x.x.x.x"
NAMESERVER_2="x.x.x.x"
BROADCAST="x.x.x.255"
BROADCAST="x.x.x.255"
BROADCAST="x.x.x.255"
BROADCAST="x.x.x.255"
LOOPBACK="127.0.0.0/8"
LOOPBACK="127.0.0.0/8"
LOOPBACK="127.0.0.0/8"
LOOPBACK="127.0.0.0/8"
CLASS_A="10.0.0.0/8"
CLASS_A="10.0.0.0/8"
CLASS_A="10.0.0.0/8"
CLASS_A="10.0.0.0/8"
CLASS_B="172.16.0.0/12"
CLASS_B="172.16.0.0/12"
CLASS_B="172.16.0.0/12"
CLASS_B="172.16.0.0/12"
CLASS_C="192.168.0.0/16"
CLASS_C="192.168.0.0/16"
CLASS_C="192.168.0.0/16"
CLASS_C="192.168.0.0/16"
CLASS_D_MULTICAST="224.0.0.0/4"
CLASS_D_MULTICAST="224.0.0.0/4"
CLASS_D_MULTICAST="224.0.0.0/4"
CLASS_D_MULTICAST="224.0.0.0/4"
CLASS_E_RESERVED_NET="240.0.0.0/5"
CLASS_E_RESERVED_NET="240.0.0.0/5"
CLASS_E_RESERVED_NET="240.0.0.0/5"
CLASS_E_RESERVED_NET="240.0.0.0/5"
P_PORTS="0:1023"
P_PORTS="0:1023"
P_PORTS="0:1023"
P_PORTS="0:1023"
UP_PORTS="1024:65535"
UP_PORTS="1024:65535"
UP_PORTS="1024:65535"
UP_PORTS="1024:65535"
TR_SRC_PORTS="32769:65535"
TR_SRC_PORTS="32769:65535"
TR_SRC_PORTS="32769:65535"
TR_SRC_PORTS="32769:65535"
TR_DEST_PORTS="33434:33523"
TR_DEST_PORTS="33434:33523"
TR_DEST_PORTS="33434:33523"
TR_DEST_PORTS="33434:33523"