azsde
Posts: 6
Joined: Sun Jan 06, 2013 11:09 pm

Can't SSH into Pi with Hostapd

Mon Jun 18, 2018 11:29 am

Hello everyone,

I've followed this tutorial to turn my pi into an AP.

So far so good, I can connect with any machine to the PI's AP. :)

However, I can't SSH into the pi when no ethernet is plugged. :|

The connection is timing out.

As soon as I plug an ethernet cable, I can SSH into my pi again (using the AP, not the ethernet).

Am I missing something here ?

User avatar
thagrol
Posts: 3178
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Can't SSH into Pi with Hostapd

Mon Jun 18, 2018 11:40 am

Are you trying to connect by hostname or IP address?

Is the machine you're trying to connect from actually connected to the Pi's hotspot?

With two network interfaces the Pi will have two IP addresses.Which one your client is using (or which one the hostname it's ising resolves to) affect which interface on the Pi it tries to connect to.
Arguing with strangers on the internet since 1993.

azsde
Posts: 6
Joined: Sun Jan 06, 2013 11:09 pm

Re: Can't SSH into Pi with Hostapd

Mon Jun 18, 2018 11:44 am

thagrol wrote:
Mon Jun 18, 2018 11:40 am
Are you trying to connect by hostname or IP address?

Is the machine you're trying to connect from actually connected to the Pi's hotspot?

With two network interfaces the Pi will have two IP addresses.Which one your client is using (or which one the hostname it's ising resolves to) affect which interface on the Pi it tries to connect to.
Hello,

Yes, my phone is running JuiceSSH and is connected to the Pi's hotspot.

My pi has the following IPs:
  • eth0 : 172.20.1.22
  • wlan0 : 192.168.1.1
    My phone has the IP: 192.168.1.2

    As soon as I remove the ethernet cable, I loose the SSH connection, despite being connected over WiFi directly onto my Pi's AP.

    User avatar
    thagrol
    Posts: 3178
    Joined: Fri Jan 13, 2012 4:41 pm
    Location: Darkest Somerset, UK
    Contact: Website

    Re: Can't SSH into Pi with Hostapd

    Mon Jun 18, 2018 11:56 am

    Curious.

    What IP address is you phone/juicessh using to connect to the Pi? 172.20.1.22 or 192.168.1.1?
    Arguing with strangers on the internet since 1993.

    azsde
    Posts: 6
    Joined: Sun Jan 06, 2013 11:09 pm

    Re: Can't SSH into Pi with Hostapd

    Mon Jun 18, 2018 11:59 am

    thagrol wrote:
    Mon Jun 18, 2018 11:56 am
    Curious.

    What IP address is you phone/juicessh using to connect to the Pi? 172.20.1.22 or 192.168.1.1?
    192.168.1.1

    I can't even ping my pi over wifi when the ethernet is disconnected

    epoch1970
    Posts: 5203
    Joined: Thu May 05, 2016 9:33 am
    Location: Paris, France

    Re: Can't SSH into Pi with Hostapd

    Mon Jun 18, 2018 2:55 pm

    Whit Raspbian Stretch, when you unplug/plug the cable the system resets network interfaces and restarts services.
    From you description I would assume you missed something in dhcpcd.conf or hostapd.conf, and either wlan0 gets reconfigured as a client to your wifi LAN (using whatever is configured in wpa_supplicant.conf), or hostapd itself fails to restart.

    Perhaps you can check /var/log/syslog and "systemctl status" and find a clue?
    "S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

    azsde
    Posts: 6
    Joined: Sun Jan 06, 2013 11:09 pm

    Re: Can't SSH into Pi with Hostapd

    Tue Jun 19, 2018 9:42 am

    This subject can be closed, it was a phone issue.

    For some reason, when no internet is available on the wifi AP, it tries to connect to 192.168.1.1 over my LTE connection :|

    For the time beeing I turn off the data and I can connect just fine.

    epoch1970
    Posts: 5203
    Joined: Thu May 05, 2016 9:33 am
    Location: Paris, France

    Re: Can't SSH into Pi with Hostapd

    Wed Jun 20, 2018 9:24 am

    azsde wrote:
    Tue Jun 19, 2018 9:42 am
    For some reason, when no internet is available on the wifi AP, it tries to connect to 192.168.1.1 over my LTE connection :|
    Apple calls that "wifi assist", a feature where the phone tries to use 3G/4G to connect when the interface on the wifi network can't reach some destination.
    When you disconnect ethernet from the Pi, the phone has no longer access to the Internet via the default gateway, so "wifi assist" kicks-in.

    You can configure your DHCP server instance on the Pi to not send the "default gateway" information.
    The phone will use wifi to connect to 192.168.1.0 and its other interface to connect to the Internet.
    With dnsmasq, you would add to your config "dhcp-option=3", which suppresses sending the default gateway address to clients.
    And also probably "dhcp-option=6" which tells dnsmasq not to send DNS servers information.
    "S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

    Return to “Advanced users”