klong4
Posts: 5
Joined: Fri Mar 15, 2019 7:53 pm

Using 2 USB Ethernet adapters

Fri Mar 15, 2019 10:06 pm

Hi,

I am using 2 USB LAN adapters on a rpi 3 b+ to have 2 separate devices show video through a tomcat web server. the devices have static ips and serve their own web page.

the tomcat web server loads both of the devices web apps side by side in kiosk mode through chromium. When i have the devices connected through a router everything works.

I am unable to get both of the web apps to load using the USB LAN adapters and my guess is that i have to combine/bridge them to work like a router does. need to somehow bridge eth0 eth1 and eth2.

can anyone help me with this, i have tried a few tutorials without any luck.

thanks in advance for any help.

epoch1970
Posts: 2663
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Using 2 USB Ethernet adapters

Sat Mar 16, 2019 10:05 am

how many networks do you use?
Why not a switch instead of the 2 adapters?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

klong4
Posts: 5
Joined: Fri Mar 15, 2019 7:53 pm

Re: Using 2 USB Ethernet adapters

Sat Mar 16, 2019 2:52 pm

there will only be 1 network, but with 3 total eth adapters.

I plan to have this all contained in a small box, adding a switch/hub internally to this box will make it too large. I have tried to find small hubs but have not been successful.

using a switch definitely works, i have tested it and works perfect. i was hoping to minimize the footprint of the entire project.

epoch1970
Posts: 2663
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Using 2 USB Ethernet adapters

Sat Mar 16, 2019 3:57 pm

Ok.
You need a bridge with 3 member interfaces eth0, eth1, eth2.
Make sure you have local access via the console if things go wrong.

I propose you try the following:

Code: Select all

sudo apt-get install bridge-utils

Code: Select all

sudo nano /etc/dhcpcd.conf
and add

Code: Select all

denyinterfaces br0 eth0 eth1 eth2
near the top of the file.

Next, paraphrasing the Debian Wiki:

Code: Select all

sudo nano /etc/network/interfaces
Add to the file:

Code: Select all

auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual

auto eth2
iface eth2 inet manual

auto br0
iface br0 inet dhcp
bridge_ports eth0 eth1 eth2
Then reboot.
When you're back on line, there is a good chance your IP address on the LAN will have changed.
If you run "brctl show", you should see a bridge called br0 with 3 interfaces in it.

If the USB devices are missing, or if you want to be able to disconnect/reconnect the USB devices from the bridge, you can use blocks like this instead for eth1 and eth2:

Code: Select all

auto eth1
iface eth1 inet manual
post-up ip link set dev eth1 master br0
post-up ip link set dev eth1 up
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

klong4
Posts: 5
Joined: Fri Mar 15, 2019 7:53 pm

Re: Using 2 USB Ethernet adapters

Sat Mar 16, 2019 9:25 pm

Ok thank you I will give it a try.

Also it's important to note that all eth must have static ip's which I have set in DHCP.conf. would it be possible to set the IP of the bridge as well.

epoch1970
Posts: 2663
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Using 2 USB Ethernet adapters

Sun Mar 17, 2019 12:25 am

Bridge members do not have an IP address.
The machines at the other end of the cable do.
The bridge itself commonly has an address (otherwise the Pi would not be adressable on the network)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

klong4
Posts: 5
Joined: Fri Mar 15, 2019 7:53 pm

Re: Using 2 USB Ethernet adapters

Mon Mar 18, 2019 7:31 pm

Hi,

I have tried the above steps without luck, when I run "brctl show" there is nothing listed under the bridge. Is there a step where i need to add the br0?

User avatar
pi-anazazi
Posts: 497
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Using 2 USB Ethernet adapters

Thu Mar 21, 2019 2:26 pm

I use two bridged USB-RJ45 adapters for wireshark and set them up as a bridge with these commands:

Code: Select all

ifconfig eth1 -arp promisc 0.0.0.0 up 
ifconfig eth2 -arp promisc 0.0.0.0 up 
brctl addbr br0 
brctl addif br0 eth1 
brctl addif br0 eth2 
ifconfig br0 -arp promisc 0.0.0.0 up
...adapt for your needs with third adapter. Dunno how to make this permanent on boot, though...
Kind regards

anazazi

klong4
Posts: 5
Joined: Fri Mar 15, 2019 7:53 pm

Re: Using 2 USB Ethernet adapters

Mon Mar 25, 2019 9:25 pm

pi-anazazi wrote:
Thu Mar 21, 2019 2:26 pm
I use two bridged USB-RJ45 adapters for wireshark and set them up as a bridge with these commands:

Code: Select all

ifconfig eth1 -arp promisc 0.0.0.0 up 
ifconfig eth2 -arp promisc 0.0.0.0 up 
brctl addbr br0 
brctl addif br0 eth1 
brctl addif br0 eth2 
ifconfig br0 -arp promisc 0.0.0.0 up
...adapt for your needs with third adapter. Dunno how to make this permanent on boot, though...
Thank you, adding the following to the end of the .bash_profile file got them to work at startup. Then I just set a static ip to br0 in dhcpcd.conf.

Code: Select all

 && sudo brctl addbr br0 && sudo brctl addif br0 eth0 eth1 eth2 
Thanks for all the help

Return to “Networking and servers”