{"id":256,"date":"2014-12-02T12:02:46","date_gmt":"2014-12-02T12:02:46","guid":{"rendered":"http:\/\/www.flat-planet.net\/?p=256"},"modified":"2014-12-02T12:02:46","modified_gmt":"2014-12-02T12:02:46","slug":"network-configuration-with-raspberry-pi-wifi-and-ethernet","status":"publish","type":"post","link":"https:\/\/flat-planet.net\/?p=256","title":{"rendered":"Network Configuration with Raspberry Pi &#8211; WiFi and Ethernet"},"content":{"rendered":"<p>I was configuring my Raspberry Pi (B+) on Raspbian via the ethernet port, but also wanted to get the WiFi adapter up and running. I had some issues getting both running at the same time though &#8211; don&#8217;t know why as the device is running headless, but as soon as I disconnected the ethernet cable the WiFi was working as you would expect.<\/p>\n<p>The workaround for this is a little messy, but I thought I&#8217;d share it here. First of all, use either the GUI or the config file to configure the WiFi (GUI is easier). The key point here, as I want to use a static IP when on my home network and DHCP the rest of the time, is to set the &#8216;id_str&#8217; parameter to something meaningful e.g. home_network. The id_str allows us to match a WiFi access point to an interface configuration.<\/p>\n<h2>WiFi Config File<\/h2>\n<p>This is stored in <code>\/etc\/wpa_supplicant\/wpa_supplicant.conf<\/code><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nctrl_interface=DIR=\/var\/run\/wpa_supplicant GROUP=netdev\r\nupdate_config=1\r\n\r\nnetwork={\r\nssid=&quot;network-SSID&quot;\r\npsk=&quot;my_network_key&quot;\r\nproto=RSN\r\nkey_mgmt=WPA-PSK\r\npairwise=TKIP\r\nauth_alg=OPEN\r\nid_str=&quot;&lt;strong&gt;home_static&lt;\/strong&gt;&quot;\r\n}\r\n<\/pre>\n<h2>Interfaces File<\/h2>\n<p>This is \/<code>etc\/network\/interfaces<\/code><br \/>\nNote how the <strong>iface<\/strong> name is the same as the <strong>id_str<\/strong> for the home network\/static IP configuration<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nauto lo\r\n\r\niface lo inet loopback\r\n\r\nallow-hotplug eth0\r\niface eth0 inet dhcp\r\n\r\nallow-hotplug wlan0\r\niface wlan0 inet manual\r\nwpa-roam \/etc\/wpa_supplicant\/wpa_supplicant.conf\r\n\r\niface &lt;strong&gt;home_static&lt;\/strong&gt; inet static\r\naddress 192.168.1.20\r\nnetmask 255.255.255.0\r\ngateway 192.168.1.1\r\n\r\niface default inet dhcp\r\n<\/pre>\n<h2>The Weirdness<\/h2>\n<p>For some reason if we hotplug the Ethernet port we disable wlan0 (and it makes a right mess of things as the sshd and other services aren&#8217;t bound to the correct interface any more).<\/p>\n<p>So we edit <code>\/etc\/default\/ifplugd<\/code><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nINTERFACES=&quot;eth0&quot;\r\nHOTPLUG_INTERFACES=&quot;eth0&quot;\r\nARGS=&quot;-q -f -u0 -d10 -w -I&quot;\r\nSUSPEND_ACTION=&quot;stop&quot;\r\n<\/pre>\n<p>And to give the WiFi dongle a kick at startup we add the following to <code>\/etc\/rc.local<\/code>.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# Disable the ifplugd eth0\r\nsudo ifplugd eth0 --kill\r\nsudo ifup wlan0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was configuring my Raspberry Pi (B+) on Raspbian via the ethernet port, but also wanted to get the WiFi adapter up and running. I had some issues getting both running at the same time though &#8211; don&#8217;t know why as the device is running headless, but as soon as I disconnected the ethernet cable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,63],"tags":[115,114,113,42,40,64,112],"series":[],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-linux","category-raspberry-pi","tag-config","tag-ethernet","tag-hotplug","tag-linux-2","tag-networking","tag-raspberry-pi-2","tag-wifi"],"_links":{"self":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256"}],"version-history":[{"count":1,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/256\/revisions\/257"}],"wp:attachment":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}