Setting up WiFi over SSH, without using DietPi-config

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

This is what dietpi-config says

DietPi - Network Options: Adapters ├─────────────┐
│ │
│ Ethernet : Available | Enabled | Connected │
│ Wifi : Available | Enabled | Disconnected │
│ IPv6 : Disabled │
│ Internet : Please run Internet Test │
│ Proxy : Disabled │

Under DietPi - Wireless Network Options my ssid is correct, pw is correct and mode is dhcp.

Why is it not connecting?
Gord_W

Edit: Current interfaces file

root@DietPi:/etc/network# cat interfaces
#/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.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid Williams
wireless-key xxx
wireless-mode Managed
wireless-power off
wpa-ssid Williams
wpa-psk xxx
#dns-nameservers 8.8.8.8 8.8.4.4
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

What I am eventually hoping to do is have ethernet on 10.0.0.x network and wifi on 192.168.1.x network.

I change the above interfaces file to:

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
#address 192.168.0.100
#netmask 255.255.255.0
#gateway 192.168.0.1
#wireless-essid Williams
#wireless-key xxx
wireless-mode Managed
wireless-power off
wpa-ssid Williams
wpa-psk xxx
#dns-nameservers 8.8.8.8 8.8.4.4

And the wifi is working to the point that I can ssh into .103 but it is back to the original problem with wlan0 is getting the Rx and the Tx reply is coming back through the ethernet. :evil:
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

Here is some information that is way beyond me. Maybe someone can decipher it and explain what is happening.

root@DietPi:~# ip route show
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.103

root@DietPi:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0

root@DietPi:~# ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether b8:27:eb:9e:47:6e brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DORMANT group default qlen 1000
link/ether b8:27:eb:cb:12:3b brd ff:ff:ff:ff:ff:ff

:? What is state UP mode DEFAULT/DORMANT above?

ARP
root@DietPi:~# ip neigh show
192.168.1.101 dev wlan0 lladdr 00:22:15:c6:68:4a STALE
192.168.1.101 dev eth0 lladdr 00:22:15:c6:68:4a REACHABLE
192.168.1.1 dev eth0 lladdr 64:66:b3:f4:35:f8 STALE
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

:o So, I unplugged the eithernet expecting the whole thing to stop working but I was able to ssh in with the wifi. Go figure!

Anyway, enough for tonight.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

I left it on overnight and came back this morning. Ethernet unplugged, using wifi. Everything working so I thought. Then tried to download package from internet and found that external connections were not working. Only local network.

I halted and powered down and up. Tried to ssh through wifi and couldn't get a connection. ssh: connect to host 192.168.1.103 port 22: Connection timed out NOTE! it didn't say "No route to host"

Router Wireless Status says MAC address is associated and small number of packets sent and received.
Router DHCP says dietpi with correct MAC is at 192.168.1.103

So I'm guessing but I suspect, even though the eithernet cable is disconnected it is trying to send ssh replies back to eth0 instead of wlan0 as have shown before in my earlier posts.

Something is seriously wrong here.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

Looking for help or suggestions here. I'm a beginner and this is beyond my capabilities.

When I couldn't get to the internet and before I powered down and up discussed above I did a few tests.

root@DietPi:~# ip route show
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.103

root@DietPi:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0

Note this was - first entry now missing.
root@DietPi:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0

root@DietPi:~# ip neigh show
192.168.1.101 dev wlan0 lladdr 00:22:15:c6:68:4a REACHABLE
192.168.1.1 dev wlan0 lladdr 64:66:b3:f4:35:f8 DELAY

root@DietPi:~# ping http://www.google.com
connect: Network is unreachable

root@DietPi:~# ip neigh show
192.168.1.101 dev wlan0 lladdr 00:22:15:c6:68:4a REACHABLE
192.168.1.1 dev wlan0 lladdr 64:66:b3:f4:35:f8 REACHABLE
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Fourdee »

I'm also having problems setting up a rpi3 with wifi after using ethernet for a time headless.
Looking for help or suggestions here.
Hi Gordon,

Lets take a look at this for you.

Ok, so from what I can read, WiFi isn't working correctly, no route to external sources? If that is the case its most likely a DNS/routing issue. As for the cause, not sure yet, but we can run some tests.

Few questions and tests:
  • Check signal strength (dB) on the RPi, maybe its dropping out:

    Code: Select all

    iwconfig
  • Is this onboard WiFi on RPi 3, or, USB ? (sorry if i missed you mention this in another post, cant find it)
  • Have you tried using static IP on WiFi?
  • Try removing netplug and reboot system:

    Code: Select all

    apt-get purge netplug -y
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Gord_W
Posts: 134
Joined: Sat Oct 24, 2015 6:30 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Gord_W »

Just to recap the above posts:

1. rpi3 connected to same AP with one wireless, one wired
2. Seems like wired gets rooting priority. Wired gets gateway. Any info received on wireless the reply comes back on wired. i.e. wireless Rx operates, but Tx does not and every goes through wired Tx.
3. When wired is unplugged. The Tx and gateway don't get activated on wireless. Can sent info into device but get no reply from device.
4. Tried static and dchp.
5. No problem with wifi signal. Good signal strength, no errors.

So the main problem is switching over from wired to wireless when using the same AP. See the routing table in the above posts.

I currently have ethernet on 10.0.0.x network and wifi on 192.168.1.x network. This is working as expected. The networks are being used independently and I'm not expecting any switching to occur so this is a different situation.

From what I recall removing netplug didn't make any difference.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: Setting up WiFi over SSH, without using DietPi-config

Post by Fourdee »

Ah yes, does not fallback to wlan when eth is unplugged.

Lets try bonding eth0 and wlan0:
Edit your /etc/network/interfaces file to this (change both WIFI_KEY and ssid's (FuzonWifi) entries):

Code: Select all

#/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 dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4
    bond-master bond0
    bond-primary eth0
    bond-mode active-backup

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
address 192.168.0.100
netmask 255.255.255.0
gateway 192.168.0.1
wireless-essid FuzonWifi
wireless-key WIFI_KEY
wireless-mode Managed
wireless-power off
wpa-ssid FuzonWifi
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
Reload with SystemD

Code: Select all

systemctl daemon-reload
Reboot system:

Code: Select all

reboot
Now when you unplug eth, you should get route:

Code: Select all

root@DietPi:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
192.168.0.0     *               255.255.255.0   U     0      0        0 eth0
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
sibero80
Posts: 3
Joined: Sat Mar 30, 2019 5:06 am

Re: Setting up WiFi over SSH, without using DietPi-config

Post by sibero80 »

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.

This is my current setup:

Code: Select all

#/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=

Code: Select all

#/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!
Post Reply