RPi Wi-FI Auto Connect and static IP

In a previous article, I had written about how to configure a static IP but I had not mentioned how to setup the Wi-Fi adapter to select a hotspot automatically and apply the IP address.

We need to edit the /etc/network/interfaces file. Mine looks like this:

auto lo
iface lo inet loopback
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.102
netmask 255.255.255.0
gateway 192.168.1.1
network 192.168.1.0
broadcast 192.168.1.255
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Here I setup both the adapters with static IP address but I add the wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf for the wpa configuration that we speak of.

My file looks like

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="TP-LINK"
psk="PASSWORD"

# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA

# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK

# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP

#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN
}

You can replace the ssid with your router name and the password for your access point.

Reboot and you should be done! I am not sure how what it will do without the specified access point but it works for me so…

Cheers

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s