root/floppyfw-3.0/scripts/bridge.ini

Revision 230, 3.0 KB (checked in by root, 5 years ago)

Too much for one commit but it's what I have. Also floppyfw-3.0.3

Line 
1#!/bin/sh
2
3$Id: bridge.ini,v 1.2 2005/02/05 15:37:29 thomasez Exp $
4
5. /etc/functions.inc
6. /etc/config
7
8hostname ${HOSTNAME}
9
10echo "0" > /proc/sys/net/ipv4/ip_forward
11
12( ifconfig $INSIDE_DEV > /dev/null 2> /dev/null) || {
13        echo 
14        echo "WARNING"
15        echo "Could not find two ethernet devices"
16        echo 
17        exit;
18}
19
20( ifconfig $OUTSIDE_DEV > /dev/null 2> /dev/null) || {
21        echo 
22        echo "WARNING"
23        echo "Could not find two ethernet devices"
24        echo 
25        exit;
26}
27
28if [ -f /mnt/config/open.lst ]
29 then
30   stripcr /mnt/config/open.lst /etc/open.lst
31 else
32   stripcr /mnt/tmp/open.lst /etc/open.lst
33fi
34
35
36#
37# Adding the modules here:
38#
39
40modprobe bridge > $DEBUG_LOG 2>&1
41modprobe ebtables > $DEBUG_LOG 2>&1
42modprobe ebtable_broute > $DEBUG_LOG 2>&1
43modprobe ebtable_filter > $DEBUG_LOG 2>&1
44modprobe ebtable_nat > $DEBUG_LOG 2>&1
45modprobe ebt_802_3 > $DEBUG_LOG 2>&1
46modprobe ebt_arp > $DEBUG_LOG 2>&1
47modprobe ebt_ip > $DEBUG_LOG 2>&1
48modprobe ebt_log > $DEBUG_LOG 2>&1
49modprobe ebt_mark > $DEBUG_LOG 2>&1
50modprobe ebt_mark_m > $DEBUG_LOG 2>&1
51modprobe ebt_pkttype > $DEBUG_LOG 2>&1
52
53
54brctl addbr br0               # create bridge interface
55# brctl stp br0 off           # disable spanning tree protocol on br0
56brctl addif br0 $OUTSIDE_DEV  # add outside device to br0
57brctl addif br0 $INSIDE_DEV   # add inside device to br0
58
59ifconfig $OUTSIDE_DEV up
60ifconfig $INSIDE_DEV up
61ifconfig br0 up
62
63###############################################################
64# Set default policy
65#
66ebtables -P INPUT ACCEPT
67ebtables -P OUTPUT ACCEPT
68ebtables -P FORWARD ACCEPT
69# clear existing tables
70ebtables -F
71ebtables -t nat -F
72ebtables -t broute -F
73
74#
75# Firewall rules:
76#
77
78#
79# Flushing the chains.
80#
81
82iptables -F
83for i in `cat /proc/net/ip_tables_names`; do iptables -F -t $i ; done
84iptables -X
85iptables -Z   # zero all counters
86
87#
88# Policy for chains DROP everything
89#
90iptables -P INPUT DROP
91iptables -P OUTPUT DROP
92iptables -P FORWARD DROP
93
94# Make sure NEW tcp connections are SYN packets
95iptables -A INPUT -i $OUTSIDE_DEV -p tcp ! --syn -m state --state NEW -j DROP 
96
97echo "Opening ports."
98while read myline
99 do
100  case $myline in
101   \#*)
102    ;;
103   *)
104    if [ "$myline" != "" ]
105     then
106      YOURLINE=`echo $myline | sed -e 's/,/ /'`
107      set -- $YOURLINE
108      if [ "$1" -a "$2" ]
109       then
110        echo "$1:$2"
111        iptables -A FORWARD -p TCP -d $1 --dport $2 -j ACCEPT
112        iptables -A FORWARD -p UDP -d $1 --dport $2 -j ACCEPT
113      fi
114    fi
115   ;;
116  esac
117 done < /etc/open.lst
118
119#
120# We don't like the NetBIOS and Samba leaking..
121# We don't really need these lines since the policy is drop but it's
122# so important I'll keep it.
123#
124iptables -A FORWARD -p TCP --dport 135:139 -j DROP
125iptables -A FORWARD -p UDP --dport 137:139 -j DROP
126iptables -A FORWARD -p TCP --dport 445 -j DROP
127iptables -A FORWARD -p UDP --dport 445 -j DROP
128
129#
130# Keep state and open up for outgoing connections.
131#
132iptables -A FORWARD -m state --state NEW -i ${INSIDE_DEV} -j ACCEPT
133iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
134iptables -A FORWARD -m state --state NEW,INVALID -i ${OUTSIDE_DEV} -j DROP
135
136echo "1" > /proc/sys/net/ipv4/ip_forward
137
Note: See TracBrowser for help on using the browser.