Ethernet bridge with dhcp

Issues related to configuring your network
Post Reply
steff
Posts: 2
Joined: 2007/09/26 15:43:34

Ethernet bridge with dhcp

Post by steff » 2007/09/26 16:06:13

Hello,

I'm trying to create a bridge interface br0 which uses dhcp to get the ip address.
My setup scripts are located in /etc/sysconfig/network-scripts:

ifcfg-eth0:
DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
BRIDGE=br0

ifcfg-br0:
DEVICE=br0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge
DHCP_HOSTNAME=cassini
USERCTL=no
IPV6INIT=no
PEERDNS=yes

The problem is that br0 can't get an ip address during boot which results in a long timeout.
If I run dhclient br0 after that as root, then br0 gets an IP address and everything is working.

The relevant lines from /var/log/messages (service network restart; dhclient br0):
Sep 26 17:55:57 localhost kernel: eth0: Promiscuous mode enabled.
Sep 26 17:55:57 localhost kernel: br0: port 1(eth0) entering disabled state
Sep 26 17:55:57 localhost kernel: device eth0 left promiscuous mode
Sep 26 17:55:57 localhost kernel: br0: port 1(eth0) entering disabled state
Sep 26 17:55:57 localhost network: Shutting down interface eth0: succeeded
Sep 26 17:55:58 localhost net.agent[7112]: remove event not handled
Sep 26 17:55:58 localhost network: Shutting down interface br0: succeeded
Sep 26 17:55:58 localhost network: Shutting down loopback interface: succeeded
Sep 26 17:55:58 localhost hald[4240]: Timed out waiting for hotplug event 662. Rebasing to 663
Sep 26 17:55:58 localhost sysctl: net.ipv4.ip_forward = 0
Sep 26 17:55:58 localhost sysctl: net.ipv4.conf.default.rp_filter = 1
Sep 26 17:55:58 localhost sysctl: net.ipv4.conf.default.accept_source_route = 0
Sep 26 17:55:58 localhost sysctl: kernel.sysrq = 0
Sep 26 17:55:58 localhost sysctl: kernel.core_uses_pid = 1
Sep 26 17:55:58 localhost network: Setting network parameters: succeeded
Sep 26 17:55:58 localhost kernel: ip_tables: (C) 2000-2002 Netfilter core team
Sep 26 17:55:58 localhost network: Bringing up loopback interface: succeeded
Sep 26 17:55:59 localhost kernel: ip_tables: (C) 2000-2002 Netfilter core team
Sep 26 17:55:59 localhost ifup:
Sep 26 17:55:59 localhost ifup: Determining IP information for br0...
Sep 26 17:55:59 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 4
Sep 26 17:56:03 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 9
Sep 26 17:56:08 localhost net.agent[7337]: remove event not handled
Sep 26 17:56:12 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 18
Sep 26 17:56:30 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 19
Sep 26 17:56:49 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 11
Sep 26 17:57:00 localhost dhclient: No DHCPOFFERS received.
Sep 26 17:57:00 localhost ifup: failed.
Sep 26 17:57:00 localhost network: Bringing up interface br0: failed
Sep 26 17:57:00 localhost kernel: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Sep 26 17:57:00 localhost kernel: eth0: Promiscuous mode enabled.
Sep 26 17:57:00 localhost kernel: device eth0 entered promiscuous mode
Sep 26 17:57:00 localhost kernel: br0: port 1(eth0) entering learning state
Sep 26 17:57:00 localhost network: Bringing up interface eth0: succeeded
Sep 26 17:57:05 localhost dhclient: Internet Systems Consortium DHCP Client V3.0.1
Sep 26 17:57:05 localhost dhclient: Copyright 2004 Internet Systems Consortium.
Sep 26 17:57:05 localhost dhclient: All rights reserved.
Sep 26 17:57:05 localhost dhclient: For info, please visit http://www.isc.org/products/DHCP
Sep 26 17:57:05 localhost dhclient:
Sep 26 17:57:05 localhost dhclient: Listening on LPF/br0/00:03:0d:20:23:f8
Sep 26 17:57:05 localhost dhclient: Sending on LPF/br0/00:03:0d:20:23:f8
Sep 26 17:57:05 localhost dhclient: Sending on Socket/fallback
Sep 26 17:57:05 localhost dhclient: DHCPREQUEST on br0 to 255.255.255.255 port 67
Sep 26 17:57:10 localhost dhclient: DHCPREQUEST on br0 to 255.255.255.255 port 67
Sep 26 17:57:15 localhost kernel: br0: topology change detected, propagating
Sep 26 17:57:15 localhost kernel: br0: port 1(eth0) entering forwarding state
Sep 26 17:57:18 localhost dhclient: DHCPDISCOVER on br0 to 255.255.255.255 port 67 interval 5
Sep 26 17:57:18 localhost dhclient: DHCPOFFER from 10.195.198.22
Sep 26 17:57:18 localhost dhclient: DHCPREQUEST on br0 to 255.255.255.255 port 67
Sep 26 17:57:18 localhost dhclient: DHCPACK from 10.195.198.22
Sep 26 17:57:18 localhost NET: /sbin/dhclient-script : updated /etc/resolv.conf
Sep 26 17:57:18 localhost dhclient: bound to 10.195.198.241 -- renewal in 10018 seconds.

Any ideas?

Best regards,
Stefan

yyagol
Posts: 1015
Joined: 2006/06/10 18:27:44
Location: 32 4′N 34 47′E
Contact:

Ethernet bridge with dhcp

Post by yyagol » 2007/09/27 06:25:39

You should not set DHCP upon bridge , take a look at this site
http://linux-net.osdl.org/index.php/Bridge
use [b]ADDIF=eth0[/b] insted of BOOTPROTO=dhcp , then the bridge is bind with the interface

[code][root@4t2 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000d6164711c no eth0[/code]

steff
Posts: 2
Joined: 2007/09/26 15:43:34

Re: Ethernet bridge with dhcp

Post by steff » 2007/09/28 09:57:51

Hi yyagol,

unfortunately it didn't work.
I don't get a timeout on br0 during boot but br0 doesn't get a dhcp address which makes my bridge useless because I can't establish a network connection.

If I do dhclient br0 after that, everything works fine.

Your link suggests the following commands for ethernet bridges with dhcp:
# brctl setfd br0 0
# brctl addif br0 eth0
# dhclient eth0

When I look at my configuration, eth0 gets an ip address from dhcp server during boot but br0 does not.

If I use the following commands, everything works for me, but not automagically during boot:
# brctl setfd br0 0
# brctl addif br0 eth0
# dhclient br0

Do you have any more ideas?
Do I need to turn on some magic sysconfig switches to get this working?

Best regards and thank you for your help,
Stefan

yyagol
Posts: 1015
Joined: 2006/06/10 18:27:44
Location: 32 4′N 34 47′E
Contact:

Re: Ethernet bridge with dhcp

Post by yyagol » 2007/09/29 09:48:10

I don't think tweaking the kernel got something to do with it
but i did some test at my home computer and all worked fine

[code]
[root@4t2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+
DEVICE=eth0
#BOOTPROTO=dhcp
HWADDR=00:0D:61:64:71:1C
ONBOOT=yes
BRIDGE=br0
PEERDNS=no

[root@4t2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge
USERCTL=no
IPV6INIT=no
PEERDNS=yes
STP=yes
[root@4t2 ~]#[/code]
as for the DHCP_HOSTNAME i just removed it , but not sure this will be the solution
this is you're configuration that i use and it worked , it dose take some time for DHCP but it workes
you mite consider tweaking TTL on you're DHCP server

Post Reply

Return to “CentOS 4 - Networking Support”