Description:
My team and I are working with a couple of raspberry pi 3's and an IP-Stack called PicoTCP. PicoTCP uses a TAP interface, ours is called tap0
. The tap0
interface must have it's own IP when using with PicoTCP. Unfortunately, because the tap0
interface is virtualized it has no awareness of the other raspberry pi's on the same LAN. It seems obvious that we need to bridge the tap0
interface with our ethernet interface eth0
to solve this issue (Correct me if I'm wrong). We've tried many solutions to no avail!
Technical Information:
- All Pi's are connected via ethernet to the same router
- All Pi's are running the latest version of Raspbian OS
A couple solutions we have tried: https://help.ubuntu.com/community/Network%20Bridge%20with%20a%20Tap!
auto br0
iface br0 inet dhcp
pre-up tunctl -t (tap device ""ex:tap0"") -u (tap owner) -g (owner group name)
pre-up ip link set dev eth0 down ('''Brings down ethernet''')
pre-up brctl addbr br0 ('''Adds bridge''')
pre-up brctl addif br0 eth0 ('''Adds eth0 to bridge''')
pre-up brctl addif br0 tap0 ('''Adds tap0 to bridge''')
pre-up ip link set dev tap0 up ('''Bring tap0 up''')
up chmod 0666 /dev/net/tun ('''Changes permissions on tap device to user/ owner''')
post-down ip link set dev eth0 down ('''Brings down eth0''' )
post-down ip link set dev tap0 dpwn ('''Brings down tap0''')
post-down ip link set dev br0 down ('''Brings down br0''')
post-down brctl delif br0 eth0 ('''Removes bridge between br0 & eth0''')
post-down brctl delif br0 tap0 ('''Removes bridge between br0 & tap0''')
post-down brctl delbr br0 ('''Removes bridge''')
How to bridge tap to eth0 on raspberry pi?
ip tuntap add tap0 mode tap user root
ip link set tap0 up
ip link add br0 type bridge
ip link set tap0 master br0
ip link set dev eth0 down
ip addr flush dev eth0
ip link set dev eth0 up
ip link set eth0 master br0
ip link set dev br0 up
http://prssrp.blogspot.com/2014/02/raspberry-pi-openvpn-server-bridge-mode.html
#!/bin/bash
#################################
# Set up Ethernet bridge on Linux
# Requires: bridge-utils
#################################
# Define Bridge Interface
br="br0"
# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap="tap0"
# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip="192.168.10.253"
eth_netmask="255.255.255.0"
eth_broadcast="192.168.10.255"
for t in $tap; do
openvpn --mktun --dev $t
done
brctl addbr $br
brctl addif $br $eth
for t in $tap; do
brctl addif $br $t
done
for t in $tap; do
ifconfig $t 0.0.0.0 promisc up
done
ifconfig $eth 0.0.0.0 promisc up
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
PicoTCP Utilizing tap0
interface:
struct pico_device* init_picotcp(void) {
struct pico_device *dev;
struct pico_ip4 ipaddr, netmask, local;
pico_string_to_ipv4("tap0", &local.addr);
dev = pico_ipv4_link_find(&local);
if(!dev) {
printf("FAIL!\n");
return NULL;
}
pico_string_to_ipv4(serv.ipv4_addr.c_str(), &ipaddr.addr);
pico_string_to_ipv4(serv.netmask.c_str(), &netmask.addr);
pico_ipv4_link_add(dev, ipaddr, netmask);
return dev;
}
This line:
pico_ipv4_link_add(dev, ipaddr, netmask);
Opens the created tap0
device with a specific IP and Netmask.
Notably:
None of these solutions worked for us.
ip addr add 192.168.3.2/24 dev tap0
etc.? Maybe try both the same IP addr as the bridge, and a different one. Note that normally the "ports" of a bridge don't get an IP addr of their own.