Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / ifupdown / examples / | server ip : 172.67.156.115 your ip : 172.69.130.124 H O M E |
Filename | /usr/share/doc/ifupdown/examples/bridge |
Size | 1.97 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:50 |
Last modified | 22-Jun-2012 05:52 |
Last accessed | 06-Jul-2025 23:57 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/bin/sh
# The following script example, if dropped in /etc/network/if-pre-up.d/
# and under /etc/network/if-down.d/, will manage to configure a bridge
# if defined in the /etc/network/interfaces file as either:
#
# Note: The bridge-utils package already provide a similar (more
# powerful) script this is just provided here for convenience and to
# show how the /etc/network/if-*.d/ methods can be defined.
#
# [ a bridge with an associated IP address ]
# iface br0 inet static
# bridge-ifaces eth0 eth1
# address 192.168.1.1
# netmask 255.255.255.0
# [ a bridge which acts as an anonymous bridge ]
# iface br0 inet manual
# bridge-ifaces eth0 eth1
# up ifconfig $IFACE up
#
# For more information read:
# http://bridge.sourceforge.net/howto.html
brctl=`which brctl`
# Notice that the bridge-utils package must be installed and
# we need to have the BRIDGE_IFACES in order to work
[ "$IF_BRIDGE_IFACES" = "" ] && exit 0
if [ -z "$brctl" ] ; then
# ? Somebody is trying to use us without having bridge-utils?
echo "Cannot find the 'brctl' program to setup the bridge"
echo "Hint: Have you installed the bridge-utils package?"
exit 1
fi
# Check all interfaces before proceeding
for i in $IF_BRIDGE_IFACES; do
ip link show $i >/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "Interface $i is not available, aborting"
exit 1
fi
done
if [ "$MODE" = "start" ] ; then
# We are being called by ifup:
# Bring up all the bridge interfaces
for i in $IF_BRIDGE_IFACES; do
ifconfig $i 0.0.0.0 up
done
# And now add the bridge itself and the interfaces which are part
# of the bridge
brctl addbr $IFACE
for i in $IF_BRIDGE_IFACES; do
brctl addif $IFACE $i
done
elif [ "$MODE" = "stop" ]; then
# We are being called by ifdown:
# Remove the bridge itself and the bridge association
for i in $IF_BRIDGE_IFACES; do
brctl delif $IFACE $i
done
brctl delbr $IFACE
# Bring down all the bridge interfaces
for i in $IF_BRIDGE_IFACES; do
ifconfig $i down
done
fi
exit 0
# The following script example, if dropped in /etc/network/if-pre-up.d/
# and under /etc/network/if-down.d/, will manage to configure a bridge
# if defined in the /etc/network/interfaces file as either:
#
# Note: The bridge-utils package already provide a similar (more
# powerful) script this is just provided here for convenience and to
# show how the /etc/network/if-*.d/ methods can be defined.
#
# [ a bridge with an associated IP address ]
# iface br0 inet static
# bridge-ifaces eth0 eth1
# address 192.168.1.1
# netmask 255.255.255.0
# [ a bridge which acts as an anonymous bridge ]
# iface br0 inet manual
# bridge-ifaces eth0 eth1
# up ifconfig $IFACE up
#
# For more information read:
# http://bridge.sourceforge.net/howto.html
brctl=`which brctl`
# Notice that the bridge-utils package must be installed and
# we need to have the BRIDGE_IFACES in order to work
[ "$IF_BRIDGE_IFACES" = "" ] && exit 0
if [ -z "$brctl" ] ; then
# ? Somebody is trying to use us without having bridge-utils?
echo "Cannot find the 'brctl' program to setup the bridge"
echo "Hint: Have you installed the bridge-utils package?"
exit 1
fi
# Check all interfaces before proceeding
for i in $IF_BRIDGE_IFACES; do
ip link show $i >/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "Interface $i is not available, aborting"
exit 1
fi
done
if [ "$MODE" = "start" ] ; then
# We are being called by ifup:
# Bring up all the bridge interfaces
for i in $IF_BRIDGE_IFACES; do
ifconfig $i 0.0.0.0 up
done
# And now add the bridge itself and the interfaces which are part
# of the bridge
brctl addbr $IFACE
for i in $IF_BRIDGE_IFACES; do
brctl addif $IFACE $i
done
elif [ "$MODE" = "stop" ]; then
# We are being called by ifdown:
# Remove the bridge itself and the bridge association
for i in $IF_BRIDGE_IFACES; do
brctl delif $IFACE $i
done
brctl delbr $IFACE
# Bring down all the bridge interfaces
for i in $IF_BRIDGE_IFACES; do
ifconfig $i down
done
fi
exit 0