Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Wifi as fallback LAN for Ethernet link not connected at boot #265

Closed
WolfganP opened this issue Apr 1, 2016 · 11 comments
Closed

Comments

@WolfganP
Copy link

WolfganP commented Apr 1, 2016

As per https://github.com/Fourdee/DietPi/issues/264

As a basic connectivity model for DietPi, change the concept of current exclusive LAN connection (Eth OR Wifi) to a priority based one (activate wifi with preconfigured credentials if wired ethernet not present at boot)

It may later be expanded to simultaneous connectivity / both links active model if worthy.

@spiderkeys
Copy link

Would also like to support the notion of providing simultaneous connectivity/bridging the two connections, regardless of whether or not the wifi is infrastructure, adhoc, or AP mode.

@Fourdee
Copy link
Collaborator

Fourdee commented Apr 2, 2016

@WolfganP
Thanks for creating the request. As v115 is nearly completed, I'll add this to v116 and start work on it after v115 is released.

@spiderkeys
Noted 👍 . We should be able to make that possible.

@Fourdee Fourdee added this to the v116 milestone Apr 2, 2016
@k-plan
Copy link
Contributor

k-plan commented Apr 4, 2016

Hi,

nice feature and can be really helpful.
Which USB Wifi adapter (chip set) will be supported in DietPi out-of-the box adhoc or AP mode?

Tested five different units (chips: 1x TI, 2x ralink, 1x realtek, 1x atheros), not only one will work.

@rhkean
Copy link
Contributor

rhkean commented Apr 4, 2016

probably best to let the kernel detect, then test for presence of wlan0.

@WolfganP
Copy link
Author

WolfganP commented Apr 8, 2016

From what I read at http://raspberrypi.stackexchange.com/questions/8851/setting-up-wifi-and-ethernet it seems that declaring both interfaces and keeping the proper credentials at wpa_supplicant.conf will work (plus disabling the hotplugging capability).
And obviously not making the selection of interfaces exclusive at dietpi-config...

@Fourdee
Copy link
Collaborator

Fourdee commented Apr 8, 2016

@rhkean @WolfganP

probably best to let the kernel detect, then test for presence of wlan0.

Yep, thats the plan.
Currently DietPi is coded to only support 1 active adapter at any time, or both when using WiFi hotspot. Basically we just need to allow the user to enable and configure both adapters at the same time, and support it throughout DietPi scripts (eg: dietpi-config). Then we will probably let the kernel decide which one is actually used, for now.

I'am aiming to start work on this later tonight and tomorrow. My son is staying at his nans for the night, so I will get some time to really dig into this :).

@WolfganP
Copy link
Author

WolfganP commented Apr 8, 2016

Great!

@Fourdee
Copy link
Collaborator

Fourdee commented Apr 9, 2016

@rhkean @WolfganP
Done, available for v116.
Wasn't as bad as I thought. Did most of the code work when I implemented the WiFi hotspot support in dietpi-config

  • You can now enable and configure both Ethernet and WiFi adapters at the same time in dietpi-config. Previously, one had to be disabled to enable the other.
  • You can also disable either adapter from dietpi-config
  • I've also rearranged the dietpi-config menus to split Networking into Adapters and NAS/Misc.

We will let the kernel decide which connection is being utilized, when both are active.

Heres the commit: Fourdee@3f532cb

@Fourdee
Copy link
Collaborator

Fourdee commented Sep 18, 2016

Removal of ifmetric to fix: https://github.com/Fourdee/DietPi/issues/515#issuecomment-247798038, breaks this ticket.

New method required.

@Fourdee Fourdee reopened this Sep 18, 2016
@Fourdee Fourdee modified the milestones: v132, v133 Sep 25, 2016
@Fourdee Fourdee modified the milestones: v133, Prototyping Oct 8, 2016
@Fourdee
Copy link
Collaborator

Fourdee commented Dec 19, 2016

Bonding: http://dietpi.com/phpbb/viewtopic.php?f=9&t=340&start=20#p4417
Does the following:

  • Allows for fallback to wlan0 when eth0 is unplugged.

@Fourdee Fourdee closed this as completed Dec 30, 2017
@sibero80
Copy link

Hello Everyone, greetings from Colombia!

Currently my Diet-pi is setup with the Hotspot package, using a Wifi dongle (wlan0) and Ethernet (eth0) as internet source.

I'm interested on adding a second WiFi adapter (wlan1) as I wish to be able to switch to wlan1 if internet eth0 gets disconnected. (or maybe bonding both eth0 and wlan1 )

This is my current setup:

#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.18
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8

# Wifi Hotspot
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
#gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4

# IP tables
up iptables-restore < /etc/iptables.ipv4.nat

From your previous post:

  1. Do yo thing the following setup would do the trick? (My second Wifi dongle has not arrived, so cannot test right now)
  2. How can I set up DHCP in wlan1 in a way that does not require the IP Adress, Netmask and Gateway to be specified?
#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.18
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
    bond-master bond0
    bond-primary eth0
    bond-mode active-backup

# Wifi Hotspot
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
#gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4

# IP tables
up iptables-restore < /etc/iptables.ipv4.nat

# Wifi Fallback
allow-hotplug wlan1
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid WIFI_SSID
wireless-key WIFI_KEY
wireless-mode Managed
wireless-power off
wpa-ssid WIFI_SSID
wpa-psk WIFI_KEY
#dns-nameservers 8.8.8.8 8.8.4.4
    bond-master bond0
    bond-primary eth0
    bond-mode active-backup

# Define bond
auto bond0
iface bond0 inet dhcp
    bond-slaves none
    bond-primary eth0
    bond-mode active-backup
    bond-miimon 100

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants