User avatar
Pencoys
Posts: 38
Joined: Fri Jan 13, 2012 8:48 am

/etc/network/interfaces for nearly all occasions

Tue Jun 05, 2012 10:43 pm

Having spent hours trying to get wireless WPA2 to work I have prepared this complete wireless dhcp interfaces config file for others to simply un hash their requirements.
I'm no expert and learning fast :-) but I hope this will help others at my level of understanding.
I know there will be many exceptions, errors etc, but I'm only trying to help..
the following is pasted into /etc/network/interfaces under the inface eth0 lines. i.e at the end of the file.
and then delete the hash from the commands that describe your wireless connection
and change UR_IP, UR_ESSID, UR_KEY ,and UR_PASS_KEY to reflect your routers setup

####################
#; start of wireless bits
#; this command stays for all configs
auto wlan0
###################
#; comments indicated by #;
#; commands indicated by #
#; remove the # to enable the command
####################
#; if using static IP then....#
#iface wlan0 inet static
# address UR_IP
#gateway UR_ROUTER_IP
#netmask 255.255.255.0
##################
#; otherwise use dhcp #
#iface wlan0 inet dhcp
###################
#; OPEN wireless config #
#wireless-essid UR_ESSID
#wireless-mode managed

###################
#; WEP wireless config #
#wireless-essid UR_ESSID
#wireless-key UR_KEY
#; end of WEP config

########################
#; WPA and WPA2 wireless config #
#; all command config lines above HERE to be #'ed except the entry auto wlan0
########################
wpa-driver wext
wpa-ssid UR_ESSID
#; wpa-ap-scan is 1 for visible and 2 for hidden hubs
wpa-ap-scan 1
#; wpa-proto is WPA for WPA1 (aka WPA) or RSN for WPA2
wpa-proto WPA
#; wpa-pairwise and wpa-group is TKIP for WPA1 or CCMP for WPA2
wpa-pairwise TKIP
wpa-group TKIP
wpa-key-mgmt WPA-PSK
#; use "wpa_passphrase UR_ESSID UR_KEY" to generate UR_HEX_KEY
#; enter the result below
wpa-psk UR_HEX_KEY
##########################
# end of wireless bits


#; hope this helps someone. cheers

atek3
Posts: 8
Joined: Thu May 24, 2012 7:16 pm

Re: /etc/network/interfaces for nearly all occasions

Fri Jun 08, 2012 6:08 am

Hmmm. I'm trying to connect to a WPA2-Personal protected WAP.

Here's my /etc/network/interfaces:


auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0

iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid MYSSID
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk MY_HEX_KEY

I'm using a Ralink RT3070 USB adapter, so I installed the rt2800usb driver. It appears to be seen just fine by the machine.

Here's my lsusb:
Bus 001 Device 005: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 099a:7202 Zippy Technology Corp.
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

when I try to go
sudo ifup wlan0

it gets to here:
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7

and fails. Any ideas on how to troubleshoot this?

Thanks atek3.

User avatar
Pencoys
Posts: 38
Joined: Fri Jan 13, 2012 8:48 am

Re: /etc/network/interfaces for nearly all occasions

Fri Jun 08, 2012 8:17 am

I'm no expert but it looks ok to my eyes.
I think the best way forward is to change your router's wireless security to open,
re-configure the /etc/network/interfaces to:-

auto wlan0
wireless-essid UR_ESSID
wireless-mode managed


Try connecting and if you still can't connect, look elsewhere for the problem.
However if you are successful, change the wireless security to WEP
re-configure the /etc/network/interfaces to:-

auto wlan0
wireless-essid UR_ESSID
wireless-key UR_KEY


and so-on till you get up to your required security level.
Don't forget that case and speiling is important, as is whitespace between e.g ..
Wireless-essid would not work (capital W rather than lowercase w)
wireless - essid would not work ( whitespace between the - )
The same goes for all other information, especially with UR-HEX-KEY where its very easy to insert a problem. ( Did you pick up the deliberate spelling error ?)

Wireless-routers are obtainable from bootsales for a few quid these days, get one as a test rig.
I have one permenently set up for test purposes. That way your normal wireless is uneffected while 'playing' and you can take your time over the process of troubleshooting without 'She-who-must be-obeyed' shouting at you for not having access to her electronic 'garden-gate' ( what I call twitter)

hope this helps, I know how frustrating it is when you are sure everythin is correct, but realise it can't be.
all the best, Mike
.

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: /etc/network/interfaces for nearly all occasions

Sat Sep 22, 2012 10:31 am

by Pencoys » Fri Jun 08, 2012 7:17 pm

I'm no expert but it looks ok to my eyes.
I think the best way forward is to change your router's wireless security to open,
That is not always an option for people. :lol:
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

User avatar
wallarug
Posts: 459
Joined: Mon May 14, 2012 8:21 am
Contact: Website

Re: /etc/network/interfaces for nearly all occasions

Sat Sep 22, 2012 11:25 am

atek3 wrote:Hmmm. I'm trying to connect to a WPA2-Personal protected WAP.

Here's my /etc/network/interfaces:


auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0

iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid MYSSID
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk MY_HEX_KEY

I'm using a Ralink RT3070 USB adapter, so I installed the rt2800usb driver. It appears to be seen just fine by the machine.

Here's my lsusb:
Bus 001 Device 005: ID 148f:3070 Ralink Technology, Corp. RT2870/RT3070 Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 099a:7202 Zippy Technology Corp.
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

when I try to go
sudo ifup wlan0

it gets to here:
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7

and fails. Any ideas on how to troubleshoot this?

Thanks atek3.
You shouldn't need to put in so much detail:

Code: Select all

auto wlan0

iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid MYSSID
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk MY_HEX_KEY
What I have in my /etc/network/interfaces file is just:

Code: Select all

auto wlan0
iface wlan0 inet dhcp
wpa-ssid "<network name>"
wpa-psk "<password>"
If you want to use a wpa_supplicant hexidecimal code instead of your letters and numbers password:
1. type in a terminal or Command line:

Code: Select all

wpa_supplicant
2. Follow the instructions left there for that program to get a hexidecimal number for wireless network.
3. Paste that hex-number into the wpa-psk area of /etc/network/interfaces

Good Luck.
RPi Hardware Guide

App Store: https://itunes.apple.com/us/app/rpi-hardware-guide/id723108328?ls=1&mt=8
Play Store: https://play.google.com/store/apps/details?id=org.cmdenterprises.rpihardwareguide

http://www.youtube.com/user/CMDenterprises

jun3rd
Posts: 1
Joined: Wed Mar 05, 2014 7:18 pm

Re: /etc/network/interfaces for nearly all occasions

Wed Mar 05, 2014 7:21 pm

Thank you so much. This was so helpful.

Phlip_
Posts: 1
Joined: Wed Jul 16, 2014 6:23 pm

Re: /etc/network/interfaces for nearly all occasions

Wed Jul 16, 2014 6:41 pm

Due to a broken home network that relies on big corps to get fixed (hah!), i have this topology:

- notebook -> ethernet cable -> hub -> cable -> RPi -> eth0
- smartphone tether to internet -> USB -> usb0

The problem is whenever I ifup usb0 I can get on the internet, but the instant I ifup eth0, the internet lapses.

Per post TBD, I added inet to my usb0 in /etc/network/interfaces:

iface eth0 inet auto
iface usb0 inet auto

Now the newbie questions. To get internet on my usb0, do I reorder the lines? That would leave eth0 open for inet if Big Data gets off its butt and fixes our home network.

iface usb0 inet auto
iface eth0 inet auto

Or do I take out the inet on eth0? Do I leave nothing there? or do I provide an alternative to inet?

iface eth0 ? auto
iface usb0 inet auto

(For extra credit, someone can help me get Win8 to share my inet on eth0! Yes, I hit the button on the source network's Properties tab;)

bd3k
Posts: 6
Joined: Thu Sep 04, 2014 12:31 am

Re: /etc/network/interfaces for nearly all occasions

Thu Sep 04, 2014 12:37 am

I was having all kinds of issues getting my WIFI working - then found this - great info - only thing I had to figure out is that wpa-ssid has to be in quotes - that's a big FYI - if you use hex value for wpa-psk you don't need quotes - but if you put in alphanumeric probably does need quotes.

Robindubois
Posts: 1
Joined: Fri Feb 20, 2015 2:37 pm

Re: /etc/network/interfaces for nearly all occasions

Wed Jun 10, 2015 2:14 am

Guy, I spent hours trying to get this to work, hours away from kids back aching, etc etc... I read a dozen confident instructions that either crashed my machine and totally corrupted the OS, (I have a backup card so not a big deal) and it's darn hard to do that. Then by chance I found your methodology you so generously took time to publish. You started out saying it works because you spent time verifying it, not just a splat of code with no statement to the effect that it works.... Your stuff worked. Immediately. My two crushed vertebrae thank you thank you thank you
!!!!

Robin du Bois
robin.dubois@gmail.com

T4b
Posts: 18
Joined: Mon Aug 17, 2015 2:52 pm

Re: /etc/network/interfaces for nearly all occasions

Fri May 06, 2016 2:14 pm

You are making it more complicated that it is.

In fact

Code: Select all

allow-hotplug wlan0 #this doesn't hurt but is only useful for usb-wifi dongles
auto wlan0
iface wlan0 inet dhcp
  wpa-ssid "SSID"
  wpa-psk "Passphrase"
at the end of the file (commenting out anything else regarding wlan which might already be there) should do the job in 90% of cases (that is, standard wlan networks with visible SSIDs and using WPA-security {which is the only secure one} based on passhrases). Some (usually corporate or university) networks use another means of authentication (user+password) which I don't know how to configure like this.
For more than one adapter add anlogous stanzas with wlan0 replaced with wlan1 etc.

I know this is gravedigging, but this thread, old as it is, is a prominent result in search engines.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: /etc/network/interfaces for nearly all occasions

Fri May 06, 2016 2:22 pm

T4b wrote:You are making it more complicated that it is.

In fact

Code: Select all

allow-hotplug wlan0 #this doesn't hurt but is only useful for usb-wifi dongles
auto wlan0
iface wlan0 inet dhcp
  wpa-ssid "SSID"
  wpa-psk "Passphrase"
at the end of the file (commenting out anything else regarding wlan which might already be there) should do the job in 90% of cases

I know this is gravedigging, but this thread, old as it is, is a prominent result in search engines.
So now you are adding a currently live element claiming that you should set up your wifi stuff in the /etc/network/interfaces file? Is that really helping?

Return to “Beginners”

Who is online

Users browsing this forum: Bi0Ph34r and 57 guests