1

I have a Raspberry Pi 2 rocking Wheezy. It generally has both a dedicated Ethernet cable plugged in that I have set to a static IP. And a wifi dongle (Alfa AWUS036H) that I also like to use with a static IP.

What should my interfaces file look like? I want the Pi to auto-detect what interfaces are plugged in, and if both interfaces are plugged in at the same time, I'd like the Pi to choose Ethernet.

This is my current interfaces file, any help is greatly appreciated.

auto lo

iface lo inet loopback
iface eth0 inet static
address 192.168.1.199
netmask 255.255.255.05
gateway 192.168.1.1

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.199
netmask 255.255.255.0
gateway 192.168.1.1
wpa-passphrase mypasswordhere
wpa-ssid myssidhere
totalconfusion
  • 29
  • 1
  • 1
  • 6

2 Answers2

2

wicd will let you select options to force use of the wired ethernet if present, otherwise try to connect with wireless. It introduces a bit more complexity in the form of a daemon, but gives a lot of flexibility with wireless configuration. You can configure it from the command prompt with wicd-curses.

Your /etc/network/interfaces looks OK to me. Are you having problems with interfaces connecting, or just trying to prefer the wired connection?

bobstro
  • 3,998
  • 14
  • 27
2

The following link shows 3 ways of setting up WiFi, http://www.raspberrypi.org/documentation/configuration/wireless/README.md

Te easiest is to set up WiFi is using GUI, but if you follow the detailed instructions you can do via the command line.

When the ethernet cable is connected, wpa-roam causes the wireless to becomes inactive. This is normal behaviour. wpa_supplicant.conf contains the usernames and passwords. This can be setup to support multiple networks e.g. home and work etc.

The default settings in /etc/network/interfaces should be something like

Edit 2015-09-09 Raspbian changed the way DHCP works, and the following is not current since the May 2015 release. The link above has been changed for the new setup.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

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

iface default inet dhcp

The above uses dhcp which is the best method as it works on different networks. You can reserve IP in your router if you want consistent IP addresses. If you want you can use static IP, but you cannot assign the same IP to multiple interfaces, each needs a distinct IP.

Milliways
  • 59,840
  • 31
  • 101
  • 209