0

I want to setup multiple network for wifi. One for my home and another for my office. I took the reference from stackoverflow but it did not work in mine. It works if i use the ethernet but not when using wifi dongle. Here how i setup for multiple wifi

/etc/network/interfaces

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

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


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

/etc/wpa_supplement/wpa_supplement.conf

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

network={
        scan_ssid=1
        ssid="MiRouter"
        psk="4444333221"
        id_str="home"
        priority=1
        key_mgmt=WPA-PSK
}

network={
        ssid="companyssid"
        psk="password"
        id_str="office"
        priority=2
}

I am using raspberry pi 2 and OS is raspbian stretch. What have i missed here?

Before the configuration was following and it was working

source-directory /etc/network/interfaces.d

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0


iface wlan0 inet dhcp
wpa-scan-ssid 1
   wpa-ap-scan 1
   wpa-key-mgmt WPA-PSK
   wpa-proto RSN WPA
   wpa-pairwise CCMP TKIP
   wpa-group CCMP TKIP
        wpa-ssid "MiRouter"
        wpa-psk "4444333221"
iface default inet dhcp
milan
  • 135
  • 1
  • 7
  • DO NOT add additional detail into comments - EDIT into your question. `ssh` is NOT enabled by default. Post output of `ip a` – Milliways Aug 23 '18 at 17:41
  • first test ... after pi has booted, what do you see in the output of `ifconfig` - do you even see a `wlan0` (or `wlx????????????`) device? is its IP address `192.168.31.94` like you've mentioned in a comment below? Check the output of `dmesg` - any errors pertaining to wifi device there? You haven't specified what wifi dongle you are using. You may have one not compatible with RPi – Jaromanda X Aug 23 '18 at 23:34
  • nup it used to work before when i have configuration done on /etc/network/interfaces but it was done for only one network. when i research for multiple network, most of the user recommended the configuration in wpa_supplement.conf and i tried the same and it's not working now. – milan Aug 24 '18 at 03:06

1 Answers1

1

If you are using Stretch you SHOULD NOT modify /etc/network/interfaces (indeed you can just delete it).

Your wpa_supplicant looks OK, although it contains un-necessary lines.

You should set Wi-Fi country e.g country=AU - not sure if absolutely necessary for Pi2, but still should be set.

See How to set up networking/WiFi which shows the correct contents of the files.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • I switched to the default /etc/network/interfaces and removed priority from the wpa_supplicant but its not working still. The wifi dongle gets blinked but wifi is still not working.I get this issue `ssh: connect to host 192.168.31.94 port 22: Operation timed out` – milan Aug 23 '18 at 16:42
  • Did you add your country code? – Dirk Aug 23 '18 at 17:26
  • sorry i did not add the country code – milan Aug 24 '18 at 09:08
  • So is it working with the correct country code? – Dirk Aug 25 '18 at 11:14