I'm trying to connect the raspberry to the ethernet and wifi at the same time, but don't work.
Raspberry infos:
Model: Pi Model 3B+ V1.3
/etc/dhcpcd.conf:
# A sample configuration for dhcpcd. See dhcpcd.conf(5) for details.
Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel
Inform the DHCP server of our hostname for DDNS.
hostname
Use the hardware address of the interface for the Client ID.
clientid
or
Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
Some non-RFC compliant DHCP servers do not reply with this set.
In this case, comment out duid and enable clientid above.
#duid
Persist interface configuration when dhcpcd exits.
persistent
Rapid commit support.
Safe to enable by default because it requires the equivalent option set
on the server to actually work.
option rapid_commit
A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
Most distributions have NTP support.
#option ntp_servers
A ServerID is required by RFC2131.
require dhcp_server_identifier
Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
Example static IP configuration:
interface eth0
static ip_address=10.10.7.201/21
static routers=10.10.0.1
#static domain_name_servers=
#static domain_search=
/etc/network/interfaces:
#iface default inet dhcp
# 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
/etc/wpa_supplicant/wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=it
network={
ssid="xxxx"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
psk="xxxx"
id_str="home"
pairwise=CCMP TKIP
group=CCMP TKIP
priority=5
}
Network description
I need to connect both because:
- The wifi provide network connectivity for ssh and internet (DHCP)
- The ethernet connect to the local network and communicate with a PLC (Programmable logic controller) (Static IP: 10.10.7.201)
Actually my laptop is temporarily connected to both the network because the PLC needs to be programmed, so I have connected all to my laptop.
As asked in the comments:
The Raspberry is connected wireless as client uplink to the internet router. It does not provide an access point. On the ethernet side there is a device wired connected to the Raspberry. The wired subnet is local and has no connection to the internet. I can confirm that.
Are there more devices on the wired subnet using a switch?
On the switch there are connected:
- Raspberry as 10.10.7.201
- PLC as 10.10.7.200
- MyLaptop as 10.10.7.3
Are there other devices wireless connected to the internet router?
Yes, there are many devices (It is the company network)
Should wireless connected devices communicate with wired connected devices?
No, the Raspberry is the only one device that must access the wired connected device (PLC). Essentially I have a Python flask webserver on the raspberry that act as interface between the user that connect to the webpage (using the wirless raspberry IP) and the PLC (That is on the wired connection)
ip r
output:default via 10.10.0.1 dev wlan0 proto dhcp src 10.10.4.195 metric 200 10.10.0.0/21 dev wlan0 proto dhcp scope link src 10.10.4.195 metric 200
Problem Description
The problem is that when I connect the Ethernet cable, the raspberry is unreachable on the WiFi network and can't access the internet from it, but both seems to be connected ifconfig
:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.7.201 netmask 255.255.248.0 broadcast 10.10.7.255
inet6 fe80::2fc5:49ad:9818:aaa0 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:bf:5a:f8 txqueuelen 1000 (Ethernet)
RX packets 5364 bytes 388068 (378.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8582 bytes 501093 (489.3 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<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 3154 bytes 524871 (512.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3154 bytes 524871 (512.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.10.4.195 netmask 255.255.248.0 broadcast 10.10.7.255
inet6 fe80::f7bc:436f:a335:bff9 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:ea:0f:ad txqueuelen 1000 (Ethernet)
RX packets 61566 bytes 10678751 (10.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 30 bytes 4374 (4.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
When I diconnect the ethernet cable, the raspberry is reachable on the wifi connection and I can connect to it using SSH.
Attempts
I have looked on google how to setup both simultaneously and I have found this article, it is very old, but as you can see in the comment it should work.
NOTE:
/etc/network/interfaces
is not actually used on the new raspberry, so I have edited the/etc/dhcpcd.conf
instead./etc/default/ifplugd
doesn't exist, so I have tried to install itapt-get install ifplugd
and cofigured as in the answer, I have also added the line in/etc/rc.local
.
Question
Do you have any tips for me on how I can correctly setup both connection to work?
I have tried to edit the /etc/dhcpcd.conf
file to set the metric:
interface eth0
static ip_address=10.10.7.201/21
metric 300
#static routers=10.10.0.1
#static domain_name_servers=
#static domain_search=
interface wlan0
metric 200
Now the WiFi is reachable but not the ethernet cable, maybe I'm missing some route add
command to perform?
ip r
– Carlo Zanocco Oct 05 '20 at 09:43