-1

I have a problem cofiguring Raspberry's 2B wifi connection. I have a usb wifi adapter that is detected by raspberry. What I want to achive is to connect to wifi immediately after boot. I need only to connect to two diffrent wifi connections: one at home, and one when using Android phone as a modem. Also i want IP in home to be static

my /etc/wpa_supplicant/wpa_supplicant.conf looks like this:

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

network={
ssid="Name of home wifi"
psk="home wifi pass"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="home"
}

network={
ssid="android phone wifi name"
psk="android wifi pass"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="android"
}

and my /etc/network/interfaces looks like this

source-directory /etc/network/interfaces.d

auto wlan0

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
iface home inet static
address 192.168.1.155
netmask 255.255.255.0
gateway 192.168.1.1
iface android inet static
address 192.168.43.155
netmask 255.255.255.0
gateway 192.168.43.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
larsks
  • 655
  • 1
  • 6
  • 17

1 Answers1

0

I am no expert in using wpa_supplicant but you seem to mix some things:

You have only one ethernet interface (there you plug your cable in): eth0

I suppose you do also have only one wifi adapter / interface: wlan0

I guess you do not have any interfaces named home or android. It looks to me like if you are trying to create static IP's. Depending on the wifi that you connect to, you want to have different IP's. I do not know how to solve this. But I am pretty sure that it is not done in the way you are doing it actl.

Rewrite your /etc/network/interfaces. But first create a backup of that file cp /etc/network/interfaces /etc/network/interfaces_backup:

auto lo
iface lo inet loopback

auto eth0 
iface eth0 inet dhcp

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

Now with iface wifi0 inet dhcp you should recieve an IP assigned from the dhcp-server of the router. To test your configuration on this command should do the job: sudo wpa_supplicant -i wlan0 -D wext -c /etc/wpa_supplicant/wpa_supplicant.conf -d If you can establish the connection reboot and check if it does automatically.

If you are interested in the different options of wpa_supplicant.conf check this file: https://media-cdn.ubuntu-de.org/wiki/attachments/44/28/wpa_supplicant.conf.examples

Edit:

One more thing to note: Depending on your Linux version you might need to do configurations in /etc/dhcpcd.conf dhcpcd vs /etc/network/interfaces

To find out info about your Linux: uname -a and lsb_release -a

AlexOnLinux
  • 397
  • 2
  • 5