13

I am running Arch Linux (on a Raspberry Pi 3) and tried to connect both the Ethernet and the Wi-Fi to the same network. route shows me the following:

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    1024   0        0 eth0
default         gateway         0.0.0.0         UG    1024   0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
gateway         0.0.0.0         255.255.255.255 UH    1024   0        0 eth0
gateway         0.0.0.0         255.255.255.255 UH    1024   0        0 wlan0

ip addr shows me the following:

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b8:27:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.103/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 85717sec preferred_lft 85717sec
    inet6 fe80::ba27:ebff:fee4:4f60/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b8:27:YY:YY:YY:YY brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.102/24 brd 192.168.1.255 scope global dynamic wlan0
       valid_lft 85727sec preferred_lft 85727sec
    inet6 fe80::ba27:ebff:feb1:1a35/64 scope link
       valid_lft forever preferred_lft forever

Both wlan0 and eth0 interfaces were able to get an IP address from the router.

But it turns out that only one of these interfaces ever works. The other interface cannot be pinged and is not connectable. Usually it's the Ethernet that works but sometimes it's the Wi-Fi.

What's happening? What can I do to make this work?

4
  • I assume IPv4? It works on my Ubuntu desktop after ARP starts working. What address are you pinging from? What address are you pinging? What does arp show on each side. What does tcpdump -i <interface> -v arp show on all relevant interfaces on both sides? Can you get a packet capture on the switch/router?
    – Mikel
    Commented Apr 29, 2017 at 16:25
  • Yes, I'm using IPv4. I'm pinging192.16.1.103 and 192.168.1.102, the two IP addresses assigned.
    – rityzmon
    Commented Apr 29, 2017 at 16:27
  • From another machine on 192.168.1.0/24? Please add arp output to your question.
    – Mikel
    Commented Apr 29, 2017 at 16:28
  • 1
    See also lwn.net/Articles/45373
    – Mikel
    Commented Apr 29, 2017 at 16:36

2 Answers 2

6

As you have found out, from the routing perspective, while possible, it is not ideal to have addresses from the same network in different interfaces.

Routing expects a different network per interface, and ultimately one of them will take precedence over the other in routing, since they overlap.

The advised solution for having more than one interface connected to the same network is to aggregate them together in a bridge interface.

The bridge interface will "own" the IP address, and the actual real interfaces are grouped as a virtual single entity under br0.

allow-hotplug eth0
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports eth0 wlan0
    

Debian Linux: Configure Network Interfaces As A Bridge / Network Switch

3
  • 1
    But still with the bridge, in most topologies, only one of them will wind up getting used because the other one will be shut down by spanning tree — or if spanning tree is turned off then you will have a devastating loop in the network.
    – Celada
    Commented May 1, 2017 at 8:55
  • @Celada They end up being a single entity, and work quite well. I have had such setup working for years to create a single entity out of my wireless and cabled network at home to be able to stream from wireless to my Apple TV (in the wired network), and it works beautifully. Commented May 1, 2017 at 9:02
  • it talks stp by default, at home my switch is not smart enough to understand it. Commented May 1, 2017 at 9:11
2

This is more an addendum than a complete solution. [Since I don't have enough "reputation points" to comment.]

You first have to make both interfaces work independently. Then, instead of bridging, you can also load balance outgoing connections across both interfaces.

https://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html

I started out with this, two devices with default route to the internet configured by network manager:

❯ ip route
default via 192.168.0.1 dev eno1 proto dhcp metric 100 
default via 192.168.0.1 dev wlp4s0 proto dhcp metric 600 
169.254.0.0/16 dev wlp4s0 scope link metric 1000 
192.168.0.0/24 dev eno1 proto kernel scope link src 192.168.0.246 metric 100 
192.168.0.0/24 dev wlp4s0 proto kernel scope link src 192.168.0.213 metric 600 

Then I used the command, described here under load balancing:

https://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html

❯ P1=192.168.0.1
❯ P2=192.168.0.1
❯ IF1=eno1
❯ IF2=wlp4s0
❯ ip route add default scope global nexthop via $P1 dev $IF1 weight 1 \     
            nexthop via $P2 dev $IF2 weight 1

Voala! I get connections through both devices.

❯ ip route                                                                  
default 
    nexthop via 192.168.0.1 dev eno1 weight 1 
    nexthop via 192.168.0.1 dev wlp4s0 weight 1 
default via 192.168.0.1 dev eno1 proto dhcp metric 100 
default via 192.168.0.1 dev wlp4s0 proto dhcp metric 600 
169.254.0.0/16 dev wlp4s0 scope link metric 1000 
192.168.0.0/24 dev eno1 proto kernel scope link src 192.168.0.246 metric 100 
192.168.0.0/24 dev wlp4s0 proto kernel scope link src 192.168.0.213 metric 600 

That might make debugging more difficult if I have connection trouble ;)

And I don't know how to persist the configuration across reboots yet, especially in combination with network manager.

1
  • Welcome to the site, and thank you for your contribution. Although it is not really an issue in this case where there is only one other answer, in general, please indicate the answer you are refering to in your post, as display order may depend on user settings. You can use the URL available via the "share" button below that answer to insert a link in your post.
    – AdminBee
    Commented Apr 21, 2020 at 14:11

You must log in to answer this question.

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