Page 1 of 1

[SOLVED] Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 2:57 am
by roger314159265
Hello, I am trying to use an ethernet cable plugged into the RP3B+ and my Macintosh to run VNC, while simultaneously using RP3B+ WiFi for an internet connection. While the VNC functionality is working perfectly, the internet connection is not. My home WiFi network is displayed in Raspbian as available, and after entering the network password, it becomes the first network in the list and is checked. However the Chromium browser can not access the internet, though the VNC connection continues to work. I am using the RP3B+ in a headless configuration, without a directly connected display or keyboard or mouse, just the VNC connection. However I do also have working SSH access via a USB to TTL serial cable for configuration as needed.

From what I have read, there is an internal process that disables wlan0 when eth0 is active, and this may be the heart of the problem. However, the previous posts I've seen related to this issue do not seem to apply to the most current Raspbian version. For example, there are references to the ifplugd process, but that does not seem to be running in the current system.

If anyone out there is up-to-speed on addressing this issue under Raspbian Buster kernel version 4.19 with regard to getting eth0 and wlan0 working simultaneously, eth0 for the direct cable connection for VNC and wlan0 for WiFi access, your help would be greatly appreciated, and would likely help many other as well. Thanks in advance for any help!

The following information from ifconfig may help:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.2 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::8dbd:d22a:b51b:862c prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:df:94:20 txqueuelen 1000 (Ethernet)
RX packets 3781 bytes 323464 (315.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5412 bytes 5031325 (4.7 MiB)
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 21 bytes 1244 (1.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 21 bytes 1244 (1.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.208 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d845:8a2a:dd1b:600d prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:8a:c1:75 txqueuelen 1000 (Ethernet)
RX packets 107 bytes 23966 (23.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 140 bytes 23739 (23.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Re: Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 1:31 pm
by topguy
Output from "ip route" command could also be enlightening.

Having subnet 192.168.1.X on wlan and 192.168.2.X for eth0 seems it should be workable.
But the eth0 interface should not have a "standard gateway" defined, if it does then the trafiic that should have gone to the internet goes the wrong way.

Re: Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 2:32 pm
by roger314159265
Here is the result from ip route:

default via 192.168.2.1 dev eth0 proto dhcp src 192.168.2.2 metric 202
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.208 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.208 metric 303
192.168.2.0/24 dev eth0 proto dhcp scope link src 192.168.2.2 metric 202

Re: Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 2:44 pm
by epoch1970
The traffic to the Internet goes via the default route.
There are 2 default routes, Linux chooses the one with lower metric: 202.

I understand you want the route via wlan0 to be chosen, its priority should be set to a value lower than 202 instead of 303.
This is done with the metric keyword in dhcpcd.conf. Search the forum around “interface priority” “route priority” or “metric”

Re: Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 3:45 pm
by roger314159265
I added:

interface wlan0;
metric 200;

interface eth0;
metric 300;

to the end of: /etc/dhcpcd.conf and rebooted.

However when I run: ip route, the original metric numbers are as before and not modified:

default via 192.168.2.1 dev eth0 proto dhcp src 192.168.2.2 metric 202
default via 192.168.1.1 dev wlan0 proto dhcp src 192.168.1.208 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.208 metric 303
192.168.2.0/24 dev eth0 proto dhcp scope link src 192.168.2.2 metric 202

In the unmodified dhcpcd.conf the file starts out:
# A sample configuration for dhcpcd.

and most of it is commented out like:
# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

Is this configuration file actually being used in Raspbian Buster 4.19? - or is a different networking system being used? For Raspbian Buster 4.19 what is the proper method for modifying the eth0 and wlan0 metrics so that I can make the wlan0 metric lower, so that it is used for an internet connection when I am simultaneously using eth0 for a direct ethernet cable connection to my laptop for VNC (which is working perfectly). Any suggestions would be appreciated. Thank you.

Re: Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 4:35 pm
by Ernst
roger314159265 wrote:
Wed Jul 03, 2019 3:45 pm
I added:

interface wlan0;
metric 200;

interface eth0;
metric 300;
see above, the ";" should not be there.

Re: [SOLVED] Simultaneously using eth0 for VNC and wlan0 for Internet

Posted: Wed Jul 03, 2019 6:02 pm
by roger314159265
The problem is solved. To recap, if you want to use WiFi on Pi (in this case Raspberry Pi 3 Model B+) to connect to the Internet, while simultaneously using the ethernet port for an ethernet cable connected to your computer to use VNC (assumed to be already working), then add these lines to the end of the /etc/dhcpcd.conf and reboot:

Code: Select all

interface wlan0
metric 200

interface eth0
metric 300
This sets the metric for wlan0 to be lower than eth0, whereas the default is higher. As stated by epoch1970 (thanks), "The traffic to the Internet goes via the default route. There are 2 default routes, Linux chooses the one with lower metric: 202." So by changing the metric numbers, you can have Internet traffic directed to WiFi (wlan0) and not the ethernet port (eth0), which in this case is being used with a dedicated ethernet cable to use VNC on another computer.

To view the metric for wlan0 and eth0 before and after this change, use the command:

Code: Select all

ip route
Hope this helps!