dalekkaan101
Posts: 8
Joined: Tue Dec 13, 2016 1:06 pm

Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 3:18 pm

Hello peeps. I'm just wondering if it is possible to connect to 2 seperate networks on a raspberry pi. I plan on the wifi having internet access but the ethernet connection being local only. Is there any problem in doing this?

Thanks for any advice.

User avatar
AdamStanislav
Posts: 150
Joined: Sun Mar 10, 2019 2:44 am
Location: Wisconsin
Contact: YouTube

Re: Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 4:39 pm

Which model of Raspberry Pi?

User avatar
default_user8
Posts: 680
Joined: Mon Nov 18, 2013 3:11 am

Re: Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 4:43 pm

dalekkaan101 wrote:
Fri Apr 19, 2019 3:18 pm
Hello peeps. I'm just wondering if it is possible to connect to 2 seperate networks on a raspberry pi. I plan on the wifi having internet access but the ethernet connection being local only. Is there any problem in doing this?

Thanks for any advice.
Research iptables
Two heads are better than one, unless one's a goat head.

dalekkaan101
Posts: 8
Joined: Tue Dec 13, 2016 1:06 pm

Re: Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 8:40 pm

Some more information, plus what I have been trying.

I basically need the raspberry pi to be able to connect to the internet via it's wifi. In addition I need to be able to connect to the pi via a local connection that has no internet(does not need it). I have successfully given the wifi a higher priority so the pi can connect to the internet, but while the wifi is turned on I cannot connect to it via ssh from the local connection(ethernet) as soon as I turn off my wifi I am able to ssh into it.

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

Re: Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 8:58 pm

By default sshd should listen on all interfaces, connecting from either side should be possible.
Are the networks on each interface are actually different, e.g. 192.168.0.0/24 for eth0 and 10.10.10.0/24 for wlan0?

If the same network is defined on both interfaces, Linux routing gets confused. It can work but that is a rather complex setup, the easiest by far is to use networks numbered differently.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

dalekkaan101
Posts: 8
Joined: Tue Dec 13, 2016 1:06 pm

Re: Connecting to 2 networls, one ethernet and 1 wifi

Fri Apr 19, 2019 10:17 pm

epoch1970 wrote:
Fri Apr 19, 2019 8:58 pm
By default sshd should listen on all interfaces, connecting from either side should be possible.
Are the networks on each interface are actually different, e.g. 192.168.0.0/24 for eth0 and 10.10.10.0/24 for wlan0?

If the same network is defined on both interfaces, Linux routing gets confused. It can work but that is a rather complex setup, the easiest by far is to use networks numbered differently.
The IP address are different. However the gateway address happens to be the same (both routers are BT), could this be causing the problem?

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

Re: Connecting to 2 networls, one ethernet and 1 wifi

Sat Apr 20, 2019 10:17 am

The networks should be different.
With multiple interfaces on the same network, by default Linux doesn’t specify which interface is used. It can receive a ping on eth0 and send the “pong” response over wlan0, creating sometimes a bit of an issue.
Other systems default to using the interface traffic was received on to reply. Lookup weak/strong network host model for details.

You can coerce Linux into using the strong network host model, but it is complicated and more importantly it is not mainstream so various services might fall on their faces because the connectivity layer doesn’t behave as usual.
The easiest way to make sure traffic is segregated by interface is to specify different networks on each interface.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

dalekkaan101
Posts: 8
Joined: Tue Dec 13, 2016 1:06 pm

Re: Connecting to 2 networls, one ethernet and 1 wifi

Sat Apr 20, 2019 5:05 pm

Okay so I changed the ip on the local router. I still have the same strange problem.
I can't ssh into the raspberry pi via the local network while the wifi is turned off. However if I turn wifi off I can then ssh into it, even if I then turn the wifi back on....so long as I ssh into the pi with the wifi turned off, I can continue to do so wifi on or off. Until that is, when I reboot the pi :o . I really don't get it.

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

Re: Connecting to 2 networls, one ethernet and 1 wifi

Sat Apr 20, 2019 5:45 pm

Not quite clear to me.
Do you have a network configuration file you can post?
"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
Speedwell68
Posts: 178
Joined: Sun May 12, 2013 5:21 am
Location: Cornwall, UK

Re: Connecting to 2 networls, one ethernet and 1 wifi

Sun Apr 21, 2019 8:24 pm

dalekkaan101 wrote:
Fri Apr 19, 2019 10:17 pm
epoch1970 wrote:
Fri Apr 19, 2019 8:58 pm
By default sshd should listen on all interfaces, connecting from either side should be possible.
Are the networks on each interface are actually different, e.g. 192.168.0.0/24 for eth0 and 10.10.10.0/24 for wlan0?

If the same network is defined on both interfaces, Linux routing gets confused. It can work but that is a rather complex setup, the easiest by far is to use networks numbered differently.
The IP address are different. However the gateway address happens to be the same (both routers are BT), could this be causing the problem?
Which BT routers are you using?

Return to “General discussion”