User avatar
marciokoko
Posts: 317
Joined: Sat Aug 27, 2016 4:33 pm

Wifi and Ethernet simultaneously RPi3

Sun May 20, 2018 12:13 am

Im trying to configure both in case one fails at any point. So I am following this article:
http://www.knight-of-pi.org/setup-simul ... erry-pi-3/

First I have the rpi3 already configured on wlan0.
Second, checked that nothing is defined in dhcpd.conf, down below I pasted the dhcpclient.conf which is all I could find:
Third Ive pasted here my current interfaces file before moving it and backing it up:
Finally, I havent added the auto eth0 or auto wlan0 blocks because I dont wanna mess anything up just yet. I want to understand what Im adding and replacing.

A/ auto eth0 means I would be automatically setting that interface up in this fashion as stated in the next few lines
B/ allow-hotplug I already have it for wlan0 means it can be modified while the OS is already up and running, without reboot?
C/ iface static means im giving it a static IP instead of now that it has a dhcp, although I dont see where in the current interfaces its configured as dhcp. But i want this since I dont want future conflicts between those 2 IPs
D/ address, netmask, broadcast & gateway are required to be configured for static ifaces
E/ what is this line for: wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

# Configuration file for /sbin/dhclient, which is included in Debian's
# dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/etc/dhcp3/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}

#lease {
# interface "eth0";
# fixed-address 192.33.137.200;
# medium "link0 link1";
# option host-name "andare.swiftmedia.com";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.33.137.250;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

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

Re: Wifi and Ethernet simultaneously RPi3

Sun May 20, 2018 1:26 pm

Do not confuse dhcpd.conf with dhcpcd.conf.
(You're not the first nor the last one.)

The package is called dhcpcd5. Installed by default on Raspbian.
On a stock raspbian machine to get both interfaces eth and wlan up and configured via DHCP the only thing you need to do is enter wireless network information in wpa_supplicant.conf.
After reboot the 2 interfaces should be up with an IP address. Ethernet has precedence (since it is faster) if both are on the same network and/or both networks have a default gateway.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
marciokoko
Posts: 317
Joined: Sat Aug 27, 2016 4:33 pm

Re: Wifi and Ethernet simultaneously RPi3

Sun May 20, 2018 3:14 pm

OK great! Thanks for the heads up.

Apparently with the configuration I currently have (without any mods to the files I posted above), the rpi picked up both automatically but it shows up on my router as the same ip. Not sure I like that idea. How is it using the same IP for both interfaces?

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

Re: Wifi and Ethernet simultaneously RPi3

Sun May 20, 2018 3:34 pm

marciokoko wrote:
Sun May 20, 2018 3:14 pm
How is it using the same IP for both interfaces?
Aha. That's linux (and systemd/dhcpcd) networking magic for you right there.
On linux the "weak network host" model is implemented by default: the IP address is an attribute of the host. In the "strong network host" model the IP is an attribute of an interface. BSD, OSX, recent versions of Windows all use the strong host model. Linux sticks with the weak host model for whatever reason. You can get linux to implement the strong host model if you use "advanced routing", which is a matter of configuration.

Among many implications (annoyances, IMHO) of the weak network model, one is that on linux any card will arp-reply on behalf of any other. Your router gets confused and shows either 1 or 2 leases. But it's allright, your Pi feels fine :)
To make sure things go well dhcpcd/systemd frantically enable and disable services and interfaces when an IP or routing conflict arises. It's all very blurry but it works. For example, you can give 2 interfaces the exact same static IP configuration in dhcpcd, and it won't croak. The Pi will connect ok, and if you look closely, you'll see only one interface is used at a time.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Advanced users”