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
22 ewarn "Could not read $CONFIG_FILE"
25 # defaults if unconfigured
26 [ -n "$BRCTL" ] || BRCTL='brctl'
27 [ -n "$BRIDGE_NAME" ] || BRIDGE_NAME='br0'
28 [ -n "$BRIDGE_DEVICES" ] || BRIDGE_DEVICES='eth0 eth1'
31 for dev in $BRIDGE_DEVICES ; do
32 ip link show dev "$dev" >/dev/null 2>&1 || return 1
36 if ! check_devs ; then
37 eerror "BRIDGE_DEVICES $BRIDGE_DEVICES do not seem to exist." >&2
41 check4progs $BRCTL || exit 1
46 einfo "Starting sniffing setup"
49 einfo "Disabling IPv6 to avoid neighbor solicitation/multicast traffic"
50 echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
52 einfo "Creating bridge device"
53 brctl addbr "$BRIDGE_NAME"
56 einfo "Bringing network device in promiscuous mode up:"
58 for i in $BRIDGE_DEVICES ; do
60 ifconfig "$i" -arp promisc 0.0.0.0 up ; eend $?
64 einfo "Adding network devices to $BRIDGE_NAME:"
66 for i in $BRIDGE_DEVICES ; do
68 brctl addif "$BRIDGE_NAME" $i ; eend $?
72 einfo "Bringing bridge $BRIDGE_NAME in promiscuous up"
73 ip link set "$BRIDGE_NAME" promisc on up ; eend $?
79 einfo "Stopping sniffing setup"
81 einfo "Removing network devices from $BRIDGE_NAME: "
84 for i in $BRIDGE_DEVICES ; do
86 brctl delif "$BRIDGE_NAME" $i ; eend $?
90 einfo "Disabling promiscuous mode on: "
92 for i in $BRIDGE_DEVICES ; do
94 ip link set "$i" promisc off ; eend $?
98 einfo "Bringing bridge $BRIDGE_NAME down"
99 ip link set "$BRIDGE_NAME" down; eend $?
101 einfo "Removing bridge device $BRIDGE_NAME"
102 ifconfig "$BRIDGE_NAME" down || /bin/true
103 brctl delbr "$BRIDGE_NAME"
106 einfo "Re-enabling IPv6"
107 echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
125 $BRCTL show ; eend $?
129 echo "Usage: $0 {start|stop|restart|status|info}"
134 ## END OF FILE #################################################################
135 # vim: ft=sh expandtab ai