I created an access point on my Raspberry PI (Raspbian) following Setting up a Raspberry Pi as an access point - the easy way the systemd-networkd way. Now I have to connect to my AP via another RPI which I do with the help of nmcli with the following command:
sudo nmcli device wifi connect MYSSID password MYPASSWORD iface wlan0
I connect successfully but I also have to make a SSH connection and a pg_dump to my access point. And when I try the static IP I set it says it can't connect to host MYIP port 22: no route to host.
I know that means that it can't find the IP, so how can I connect to my access point with SSH.
How I configured my access point. General Configuration:
sudo -Es
systemctl mask networking.service dhcpcd.service
mv /etc/network/interfaces /etc/network/interfaces~
sed -i '1i resolvconf=NO' /etc/resolvconf.conf
systemctl enable systemd-networkd.service systemd-resolved.service
ln -sf /run/systemd/resolve/resolve.conf /etc/resolv.conf
wpa_supplicant
configuration
cat > etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF
country=SI
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MYSSID"
mode=2
key_mgmt=WPA-PSK
proto=RSN WPA
psk="myPass"
frequency=2437
}
EOF
chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
systemctl disable wpa_supplicant.service
systemctl enable [email protected]
Access point configuration:
cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=172.16.2.220
DHCPServer=yes
EOF
Access point configuration with eth0, no routing
cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
Address=172.16.2.219
EOF
sudo reboot
Other RPI configuration
sudo apt install network-manager network-manager-gnome \
openvpn openvpn-systemd-resolved network-manager-openvpn \
network-manager-openvpn-gnome
And I have deleted Wireless & Wired Network
from Panel Applets
. On this RPI I have the static IP (172.16.2.231)
configured with dhcpcd
.
Edit: added configuration for my access point RPI and my other RPI
1 Answer 1
First you should append a bit mask to your ip addresses. Without it, it is assumed that you mean to use the whole class B network 172.16.0.0/16 with 65.536 ip addresses. But you have to ensure that the access point (wlan0) and the uplink (eth0) are on different subnets. Try to use this network files for the access point:
cat > /etc/systemd/network/08-wlan0.network <<EOF
[Match]
Name=wlan0
[Network]
Address=192.168.4.1/24
DHCPServer=yes
EOF
cat > /etc/systemd/network/04-eth0.network <<EOF
[Match]
Name=eth0
[Network]
#DHCP=yes
Address=172.16.2.219/24
EOF
The ip address for eth0 depends on the subnet that your internet router uses. Maybe you have to use another bit mask /16
or any other. The simplest is to use the DHCP server from your internet router. Then you don't have to worry about the setup of interface eth0.
About the configuration of the other RPi I cannot help you. NetworkManager isn't supported by Raspbian out of the box and I have never used it with Raspbian. I don't believe that it works together with dhcpcd
. You should consider just to use only default dhcpcd
or also switch over to systemd-networkd
.
Explore related questions
See similar questions with these tags.
NetworkManager
is not used by default on Raspbian;nmcli
isn't even installed (you don't say what OS you are using, so Raspbian will be presumed). If you've added that but are combining it with the adhcpcd
configuration, you may not get predictable results. Put another way, please edit all the details of what you've done to configure networking here (including the static IP).