Mailinglist Archive: opensuse (5130 mails)

< Previous Next >
Re: [SLE] Permanant bridge
  • From: Rui Santos <rsantos@xxxxxxxxxxxxx>
  • Date: Thu, 18 May 2006 15:20:07 +0100
  • Message-id: <446C8297.6000208@xxxxxxxxxxxxx>


Drew Burchett wrote:
> I have created a bridge on two Ethernet interfaces using the brctl
> commands. Everything works perfectly except that when the machine gets
> rebooted, the bridge goes away. What do I need to do to make this
> bridge permanent?
>
>
>
> Drew Burchett
>
> United Systems & Software
>
> http://www.united-systems.com
>
> Phone: (270)527-3293
>
> Fax: (270)527-3132
>
>
>
>
> --
> CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
>
>
Hi Drew,

I had the same problem you now have. To solve it I've built a script
to place at /etc/init.d , that you can control with the default
Yast->Runlevel entries.
Here is the script I use. It is not perfect bus it suits my needs...

#! /bin/sh
# Copyright (c) 1995-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Rui Santos <rsantos@xxxxxxxxxxxxx>
#
# /etc/init.d/setbridge
#
### BEGIN INIT INFO
# Provides: setbridge
# Required-Start: $syslog $network
# X-UnitedLinux-Should-Start:
# Required-Stop: $syslog $network
# X-UnitedLinux-Should-Stop:
# Default-Start: 3 5
# Default-Stop: 3 5
# Short-Description: Sets up default bridging for two network cards.
# Description: Start bridge
### END INIT INFO
#


BRIDGE_BIN=brctl

# Read config
BRIDGE_NAME=br0
BRIDGE_IFONE=eth0
BRIDGE_IFTWO=eth1
BRIDGE_ADDRESS=192.168.0.30
BRIDGE_NETMASK=255.255.255.0
BRIDGE_GATEWAY=192.168.0.254

# Shell functions sourced from /etc/rc.status:
# rc_check check and set local and overall rc status
# rc_status check and set local and overall rc status
# rc_status -v be verbose in local rc status and clear it
afterwards
# rc_status -v -r ditto and clear both the local and overall rc status
# rc_status -s display "skipped" and exit with status 3
# rc_status -u display "unused" and exit with status 3
# rc_failed set local and overall rc status to failed
# rc_failed <num> set local and overall rc status to <num>
# rc_reset clear both the local and overall rc status
# rc_exit exit appropriate to overall rc status
# rc_active checks whether a service is activated by symlinks
# rc_splash arg sets the boot splash screen to arg (if active)
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - user had insufficient privileges
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
start)
echo -n "Starting Bridge"
$BRIDGE_BIN addbr $BRIDGE_NAME
$BRIDGE_BIN addif $BRIDGE_NAME $BRIDGE_IFONE
$BRIDGE_BIN addif $BRIDGE_NAME $BRIDGE_IFTWO
ifconfig $BRIDGE_NAME $BRIDGE_ADDRESS netmask $BRIDGE_NETMASK
route add default gw 192.168.0.254
# Remember status and be verbose
rc_status -v
;;
stop)
echo -n "Shutting down Bridge"
## Stop daemon with killproc(8) and if this fails
## killproc sets the return value according to LSB.

ifconfig $BRIDGE_NAME down
$BRIDGE_BIN delif $BRIDGE_NAME $BRIDGE_IFTWO
$BRIDGE_BIN delif $BRIDGE_NAME $BRIDGE_IFONE
$BRIDGE_BIN delbr $BRIDGE_NAME
# Remember status and be verbose
rc_status -v
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
rc_exit



hope it helps you...


--
Rui Santos
http://www.ruisantos.com/

They that would give up essential liberty for
temporary safety deserve neither one of them.


< Previous Next >
References