87

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     

7 Answers7

123

Figured it out:

# ip link set br100 down
# brctl delbr br100
35
$ sudo ip link delete br0 type bridge

that's all

robo
  • 351
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.

Manwe
  • 406
  • There seems to be some division of labour between brctl and ip/ifconfig (as illustrated by the accepted answer above at https://unix.stackexchange.com/a/31765/262897) but also some overlap in functionality (as illustrated by e.g. https://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 07 '20 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 '20 at 13:48
14

How about?

docker network prune
Czollli
  • 141
10

On macOS and possibly some BSD systems:

sudo ifconfig [bridge-name] down
sudo ifconfig [bridge-name] destroy
rien333
  • 653
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
Romeo Ninov
  • 17,484
NIna
  • 29
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.

mYnDstrEAm
  • 4,275
  • 14
  • 57
  • 118