2

I'm wondering if it is possible for a Raspberry Pi 3, (which has an integrated Wi-Fi adapter). With the Pi running some network services (like a web server) can be connected to two different isolated networks at the same time.

For example, I would assign 192.168.1.10 to the wlan0 interface and 10.10.10.1 to the Ethernet iface. Assuming every interface is actually connected to its respective valid network, how would the device handle this situation? Would the web server be visible from both networks? Would I be able to reach hosts belonging both networks from inside the Pi?

  • I have not actually done this, but AFAIK you can access the server from both. You will not be able to access hosts on the other network, unless you setup bridging. Why not give it a try. – Milliways May 31 '17 at 0:40
  • Sure, I think I'll give it a try at the office today but I wanted to know if it would theorically work. I had bad experiences with stuff working perfectly during tests and then failing badly later since we didn't consider some aspetta. That's it. – Andrew May 31 '17 at 6:16
1

Did you try it and failed ?

I have a Raspberry Pi3 connected to LAN #1 using ethernet cable ( 192.168.2.1 ), and Wifi to LAN #2(192.168.3.1 ), with no problem or specific configurations,

BUT there is no connection between 2 SubNets

  • I tried and it worked partialy. The Pi connected succesfully to both networks and was able to ping hosts in either eth0 and wlan0. The problem came next was the default gateway. Unless I manually added a route entry (which isn't ideal imho) the Pi used the ethernet interface as the default one, so every request made to unknown host (i.e internet website) was redirected to eth0 iface (which may or may not be connected to a gateway). – Andrew Nov 6 '17 at 13:17
  • please explain more your needs – Guy . D Nov 6 '17 at 13:20
  • .D I added an answer explaining my results. – Andrew Nov 6 '17 at 14:26
0

Start by running:

sudo nano /etc/network/interfaces

Then edit the contents of the file so they look like this:

auto lo
iface lo inet loopback

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

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

iface NetworkOne inet dhcp
iface NetworkTwo inet dhcp

Exit the file with saving.

Then run:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf 

Edit the file so it looks like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="NetworkOneSSID"
    psk="passwordOne"
    priority=1
    id_str="NetworkOne"
}

network={
    ssid="NetworkTwoSSID"
    psk="passwordTwo"
    priority=2
    id_str="NetworkTwo"
}

Again exit the file with saving. The priority line isn't necessary, it just means the Pi will connect to one network in preference over the other.

In theory the Pi should be visible on both networks, but it's not something I've tried yet but I am meaning to get round to it.

  • Have you actually tested this? You post answers based on the older Debian networking (nothing wrong with this if you want to), but this breaks dhcpcd, and AFAIK wpa-roam will bring up EITHER WiFi OR Ethernet, not both. dhcpcd can bring up multiple interfaces. – Milliways May 31 '17 at 0:36
0

I know I'm a bit late but I'll leave here my experience in case someone still needs to know if it is possibile.

After doing some tests I figured out it is indeed possibile to connect the Pi3 to two different networks. I configured the dhcpcd.conf file to assign two different addresses (static or dynamic) to wlan0 and eth0 and the Pi could reach hosts from both network and was able to be reached from both networks.

What I didn't solve:

The only "problem" still present at the moment is that, connecting the Pi to two different networks may cause the Pi to stop being able to reach hosts outside those two networks (i.e. an internet host like a web server). Let me explain:

Let's say I connected the Pi to: WLan#1 throught WiFi and to Lan#1 throught Ethernet. If the external gateway (the one which is connected to WAN) is on WLan#1 I won't be able to reach external hosts from the Pi itself since the device automatically uses eth0 iface as the default one (so it where it redirects all requests to unknown hosts).

This results in the Pi not being able to reach an external network (which is not Wlan#1 or Lan#1, in the example above) unless you manually edit the routing table.

The Pi itself can't know which iface will have the access to a gateway so it is indeed perfectly normal that it uses the Ethernet access as the default one. The problem is that, as far as I know, there isn't any "simple" way to change the default iface. The only solution I found was to manually add a route entry through shell commands (which isn't ideal in my application scenario).

Additional notes:

Keep in mind that the Pi won't become a gateway between the two networks out of the box. If you weren't able to communicate between the two networks you still won't be able to do that, unless you configure some routing inside the Pi (which I didn't look into).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.