7

I've used the wpa_supplicant and changed the interface to use this and I can get the pi to connect to the network.

network {
    ssid="YOUR_NETWORK_NAME"
    psk="YOUR_NETWORK_PASSWORD"
}

I can also just use interfaces with

iface wlan0 inet dhcp
      wpa-ssid "network"
      wpa-psk "password"

and I get it to connect to wifi as well.

What is the difference between the two?

DJSweetness
  • 95
  • 2
  • 8

3 Answers3

5

Raspbian uses dhcpcd to manage networks. Despite the name this does more than allocate addresses; it can actively switch between networks and interfaces, and repair broken connections. /etc/network/interfaces uses wpasupplicant to provide details of known wireless networks (and other optional settings). (dhcpcd can directly call wpasupplicant, but Raspbian Jessie omitted the hook to do this, although this is included in Stretch and Buster.)

See:- How do I set up networking/WiFi/Static IP

etc/network/interfaces is used by used by ifup and ifdown.

It can be used to provide a simple static setup, which can be managed manually. The default works with dhcpcd and wpasupplicant.

One disadvantage of putting wireless settings in interfaces (apart from lack of flexibility) is that any user can read password.

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • *One disadvantage of putting wireless settings in interfaces (apart from lack of flexibility) is that any user can read password.* That's actually wrong, you can use `wpa_supplicant ssid password` and use the generated password in the interface by setting it with `wpa-psk`. – eXa Sep 11 '18 at 06:59
  • 1
    @eXa you made a typo? maybe `wpa_passphrase`? – schemacs Sep 15 '19 at 13:07
  • @schemacs Nope https://linux.die.net/man/8/wpa_supplicant – eXa Sep 16 '19 at 20:59
3

The biggest difference is that:

  • /etc/network/interfaces file refer to all interfaces of the network
  • where wpa_supplicant is focused on wireless communication.

Using interface file, you can control the interface.

wpa_supplicant, you can control the setting to connect to the wireless hub.

Sean83
  • 201
  • 2
  • 8
0

My understanding is that wpasupplicant does the WPA security and interfaces does the WiFi transport after the secure connection is made.

Mike James
  • 146
  • 1