86

How do I remove a bridge that has an IP address that was brought up manually and isn't in /etc/network/interfaces?

$ ifconfig br100                                                
    br100     Link encap:Ethernet  HWaddr 00:00:00:00:00:00                         
              inet addr:172.16.0.5  Bcast:172.16.0.255  Mask:255.255.255.0

Can't delete it:

# brctl delbr br100
bridge br100 is still up; can't delete it   

Can't bring it down with ifdown:

# ifdown br100                                                  
ifdown: interface br100 not configured     
1
  • 5
    Tried ifconfig br100 down?
    – user13742
    Feb 15, 2012 at 16:15

7 Answers 7

122

Figured it out:

# ip link set br100 down
# brctl delbr br100
3
  • 1
    To delete all bridge interfaces do sudo ip link show | grep br- | awk -F ':' '{print $2}' | tr -d ' ' | while read b; do sudo ip link set "$b" down; sudo brctl delbr "$b"; done
    – sebastian
    Nov 16, 2019 at 10:12
  • I stumbled upon an info that "brctl" is obsolete as of centos8 (and may be missing from the repos). Use "ip" as in answer by robo Feb 9, 2022 at 10:49
  • this might be useful, command to get the interface based on the ip ifconfig | grep 172.16 Jun 29, 2022 at 9:14
34
$ sudo ip link delete br0 type bridge

that's all

2
  • 3
    That is if you are on a system with iproute2 like e.g. GNU/Linux distributions.
    – phk
    Nov 19, 2016 at 15:53
  • 1
    Is the "type bridge" really required here, seem it also works fine without this Nov 28, 2019 at 18:10
16

To clarify this for future.

ifup and ifdown are commands from some flavours of linux. And are used to control network settings set in /etc/network/interfaces for debian based systems and /etc/sysconfig/network-scripts/ifcg* on Redhat based systems (I cannot comment on others).

Creating and removing interfaces manually is done by using ifconfig (or ip which is bit more tricky to use). Bridges can be controlled with brctl

So after removing all interfaces from a bridge with brctl delif <bridg> <if> it can be moved to "down state" with ifconfig br100 down (or ip link set br100 down) and can now be removed with brctl delbr br100

Please note that using network-manager to manage your networks might make your manually changed interfaces to reset.

2
  • There seems to be some division of labour between brctl and ip/ifconfig (as illustrated by the accepted answer above at unix.stackexchange.com/a/31765/262897) but also some overlap in functionality (as illustrated by e.g. unix.stackexchange.com/a/324535/262897). So to say "Bridges can be controlled with brctl" seems to be only part of the story. Is there a simple way to summarize the relationship between the two/three?
    – Christoph
    Mar 7, 2020 at 12:38
  • 1
    brctl controls the bridge-device. E.g it binds the real network devices together to create a bridge-network device. The then created bridge-device is almost like any other network device and you control it with ip/ifconfig commands. To remove real-interfaces or the bridge, one has to first bring down the interface with ip/ifconfig. In short, brctl controls bridge creation and interface bindings. ip/ifconfig control network interface (bridge device is also network interface) state and addresses.
    – Manwe
    Mar 10, 2020 at 13:48
14

How about?

docker network prune
3
  • 2
    That won’t work if the bridge wasn’t configured by Docker, will it? Oct 14, 2019 at 13:45
  • 1
    It probably won't but in my case solved the issue.
    – Czollli
    Oct 18, 2019 at 12:48
  • 3
    you solved my 3 days of desperation
    – tama
    Dec 4, 2019 at 8:44
10

On macOS and possibly some BSD systems:

sudo ifconfig [bridge-name] down
sudo ifconfig [bridge-name] destroy
1
  • Worked for me on FreeBSD!
    – Michael-O
    Jul 15, 2020 at 15:04
2

First you need to delete all the interfaces linked to your bridge using this command

ovs-vsctl del-port br-ex INTERFACE_NAME

Then you can delete the bridge

ovs-vsctl del-br br-ex
1

Also run:

virsh net-list --all  
sudo virsh net-list --all   
sudo virsh net-destroy default  
sudo virsh net-undefine default  
[...]  
sudo nmcli connection show
sudo nmcli connection delete br0
[...]  

before using the command in robo's answer if you're using GNU/Linux.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .