Skip to content

Instantly share code, notes, and snippets.

@ppanyukov
Created June 21, 2016 14:37
Show Gist options
  • Save ppanyukov/cfef9c917c308220599c8174136d64c7 to your computer and use it in GitHub Desktop.
Save ppanyukov/cfef9c917c308220599c8174136d64c7 to your computer and use it in GitHub Desktop.
Install and config of ethernet bridge on Raspberry Pi
#!/usr/bin/env bash
# Set up transparent bridge eth1->eth0
# - eth0 (built-in): attach to TT DSL router
# - eth1 (UBS) : attach to internal switch
#
# This should be executed at system startup.
# On Raspberry PI debian add this line to:
# /etc/rc.local:
# bash /path_to_this_file
# this requires the following:
# apt-get install bridge-utils
echo "$0: setting eth0-eth1 bridge"
## shutdown everything first
ifconfig eth0 down
ifconfig eth1 down
## set interfaces to promiscuous mode
ifconfig eth0 0.0.0.0 promisc up
ifconfig eth1 0.0.0.0 promisc up
## add both interfaces to the virtual bridge network
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
## optional: configure an ip to the bridge to allow remote access
ifconfig br0 192.168.1.111 netmask 255.255.255.0 up
route add default gw 192.168.1.1 dev br0
echo "$0: done bridge"
@XW-git
Copy link

XW-git commented Jul 8, 2020

Dear author,
after reboot, ifconfig shows br0, eth0,eth1 ip address. I thought eth0, eth1 are going to use br0 ip. why they have their own ip?
pi@raspberrypi:~ $ ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.8.111 netmask 255.255.255.0 broadcast 192.168.8.255
inet6 fe80::ba27:ebff:fecd:4b96 prefixlen 64 scopeid 0x20
ether b8:27:eb:cd:4b:96 txqueuelen 1000 (Ethernet)
RX packets 42 bytes 8141 (7.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 4772 (4.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth0: flags=4419<UP,BROADCAST,RUNNING,PROMISC,MULTICAST> mtu 1500
inet 192.168.1.104 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::6fd5:a9f5:54a1:c332 prefixlen 64 scopeid 0x20
ether b8:27:eb:cd:4b:96 txqueuelen 1000 (Ethernet)
RX packets 62 bytes 11794 (11.5 KiB)
RX errors 0 dropped 19 overruns 0 frame 0
TX packets 63 bytes 8167 (7.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.217.26 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::f89:dbcd:4cba:e496 prefixlen 64 scopeid 0x20
ether d8:eb:97:b9:38:75 txqueuelen 1000 (Ethernet)
RX packets 60 bytes 8491 (8.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 74 bytes 11134 (10.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.74.32.66 netmask 255.255.254.0 broadcast 10.74.33.255
inet6 fe80::a55d:2f0d:fbe8:b40b prefixlen 64 scopeid 0x20
ether b8:27:eb:98:1e:c3 txqueuelen 1000 (Ethernet)
RX packets 787 bytes 407312 (397.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 155 bytes 29504 (28.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment