3 # Purpose: script for configuring a network sniffing setup
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
9 CONFIG_FILE=/etc/grml/routersetup
10 . /etc/grml/lsb-functions
11 . /etc/grml/script-functions
15 einfo "$0 - script for configuring a network sniffing setup"
16 einfo "Configure via $CONFIG_FILE - see man 8 grml-sniff" ; eend 0
19 if ! [ -r "$CONFIG_FILE" ] ; then
20 eerror "$CONFIG_FILE could not be read."
26 if [ -z "$BRIDGE_DEVICES" ] ; then
27 eerror "Bridge devices (\$BRIDGE_DEVICES) not set in $CONFIG_FILE"
31 [ -n "$BRCTL" ] || BRCTL='brctl'
32 [ -n "$BRIDGE_NAME" ] || BRIDGE_NAME='br0'
33 [ -n "$BRIDGE_DEVICES" ] || BRIDGE_DEVICES='eth0 eth1'
36 for dev in $BRIDGE_DEVICES ; do
37 ip link show dev "$dev" >/dev/null 2>&1 || return 1
41 if ! check_devs ; then
42 eerror "BRIDGE_DEVICES $BRIDGE_DEVICES do not seem to exist." >&2
46 check4progs $BRCTL || exit 1
51 einfo "Starting sniffing setup"
53 einfo "Creating bridge device"
54 brctl addbr "$BRIDGE_NAME"
57 einfo "Bringing network device in promiscuous mode up:"
59 for i in $BRIDGE_DEVICES ; do
61 ifconfig "$i" -arp promisc 0.0.0.0 up ; eend $?
65 einfo "Adding network devices to $BRIDGE_NAME:"
67 for i in $BRIDGE_DEVICES ; do
69 brctl addif "$BRIDGE_NAME" $i ; eend $?
73 einfo "Bringing bridge $BRIDGE_NAME in promiscuous up"
74 ip link set "$BRIDGE_NAME" promisc on up ; eend $?
80 einfo "Stopping sniffing setup"
82 einfo "Removing network devices from $BRIDGE_NAME: "
85 for i in $BRIDGE_DEVICES ; do
87 brctl delif "$BRIDGE_NAME" $i ; eend $?
91 einfo "Disabling promiscuous mode on: "
93 for i in $BRIDGE_DEVICES ; do
95 ip link set "$i" promisc off ; eend $?
99 einfo "Bringing bridge $BRIDGE_NAME down"
100 ip link set "$BRIDGE_NAME" down; eend $?
102 einfo "Removing bridge device $BRIDGE_NAME"
103 ifconfig "$BRIDGE_NAME" down || /bin/true
104 brctl delbr "$BRIDGE_NAME"
123 $BRCTL show ; eend $?
127 echo "Usage: $0 {start|stop|restart|status|info}"
132 ## END OF FILE #################################################################
133 # vim: ft=sh expandtab ai