Reputation: 53
I have a Raspberry Pi (latest version of x64 OS with desktop for Pi3 B+) with an apache2 webserver and it connects to a router via WiFi wlan0. It should be available through the Internet via a domain name.
It was working, but as soon as I connected an RJ45 between the Pi and an access point, the webserver becomes unavailable.
ip route
returns:
default via 192.168.68.1 dev eth0 proto dhcp src 192.168.68.100 metric 100
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.70 metric 600
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.70 metric 600
192.168.68.0/24 dev eth0 proto kernel scope link src 192.168.68.100 metric 100
If I delete default eth0 it gets rewritten, but until it does the webserver becomes available again.
I tried a few methods:
/etc/systemd/network/10-eth0.network
[Match]
Name=eth0
[Network]
DHCP=yes
[DHCP]
UseRoutes=false
Or creating this file (but then DHCP service is not found so...)
/etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.1.70/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
metric 100
interface eth0
nogateway
metric 600
How can I prevent the Raspberry Pi from giving priority to eth0?
I need both because on eth0 I connect to multiple arduinos via WiFi, but the connection should only be used with curl --interface eth0 192.168.68.103?c=i
command.
I am losing my mind. Thanks a lot for any help!
Upvotes: 0
Views: 391
Reputation: 53
I tried another method:
ps aux | grep -E 'dhclient|dhcpcd|NetworkManager|systemd-networkd'
finally identifying who is pulling the strings: NetworkManager
nmcli connection show
I got the UUIDs given to wlan and ethernet. Then I used this command to give wlan0 a lower metric than eth0 (I changed both)
sudo nmcli connection modify -specific UUID- ipv4.route-metric 100
I then rebooted the Pi and finally wlan0 was prioritized and webserver reachable.
I don't know if this is the best solution or if it is generally acceptable but it worked for me, and I hope it may help others since I saw other similar questions.
Upvotes: 0