0

I'm setting up a wireless ap without internet connection. A client can connect to the hostapd server and obtain an ip address thanks to dnsmasq. The problem is that the client cannot ping the server and the server cannot ping the client. My server is a raspberry pi 3.

When pinging the client on the server host computer, I get ping: connect: Network is unreachable. Though the client is connected and has an ip address (tested with $ ip a).

I do not need internet access nor do I wanna set it up. I have therefor not set up a bridge.

This is my hostapd.conf:

# the interface used by the AP
interface=wlan0
# "g" simply means 2.4GHz band
hw_mode=g
# the channel to use
channel=10
# limit the frequencies used to those allowed in the country
ieee80211d=1
# the country code
country_code=SE
# 802.11n support
ieee80211n=1
# QoS support, also required for full speed on 802.11n/ac/ax
wmm_enabled=1

wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
ssid=raspi
wpa_passphrase=********

This is my /etc/dnsmasq.conf:

interface=wlan0
dhcp-range=192.168.10.2,192.168.10.30,255.255.255.0,12h
dhcp-option=3,192.168.10.1
dhcp-option=6,192.168.10.1
server=8.8.8.8
log-queries
log-dhcp
listen-address=127.0.0.1

To start the ap I run:

wpa_cli terminate;
systemctl stop dhcpcd;
systemctl start hostapd;
systemctl start dnsmasq;

To stop the ap I run

systemctl stop dnsmasq;
systemctl stop hostapd;
systemctl restart dhcpcd;

I have tried to nmap -sn 192.168.10.0/24 the network with only one result, the client, nmaping only the router at 192.168.10.1 gives nothing eventhough ssh is working on the pi (when ap is off and pi is connected to another wifi).

When doing $ ip a on the server it still has the same ip address as it had before starting the ap, when it was connected to the wifi, however, this ip address is not accessible via the "old" wifi.

In conclusion, it seems like the rpi can create an AP and give out IP addresses. It says it is connected with an ip address, but when pinging the rpi, it is not connected anywhere. The OS is freshly installed. How can I resolve this?

EDIT:

From server pov:

$ ping 192.168.10.10 # same for x.x.x.1 and x.x.x.0
ping: connect: Network is unreachable

$ ip route
# No output

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:42:db:a0 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:17:8e:f5 brd ff:ff:ff:ff:ff:ff

From client pov:

$ ping 192.168.10.1 ## same output for x.x.x.0 too
ping 192.168.10.1
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
From 192.168.10.10 icmp_seq=1 Destination Host Unreachable
From 192.168.10.10 icmp_seq=2 Destination Host Unreachable
From 192.168.10.10 icmp_seq=3 Destination Host Unreachable
^C
--- 192.168.10.1 ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5054ms
pipe 3

$ ping 192.168.10.10 ## pinging the client itself
ping 192.168.10.10
PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.
64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.122 ms
64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.042 ms
64 bytes from 192.168.10.10: icmp_seq=4 ttl=64 time=0.040 ms
^C
--- 192.168.10.10 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3039ms
rtt min/avg/max/mdev = 0.031/0.058/0.122/0.036 ms

$ ip route
default via 192.168.10.1 dev wlan0 proto dhcp metric 302 
192.168.10.0/24 dev wlan0 proto dhcp scope link src 192.168.10.10 

$ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether d4:61:9d:1b:3f:78 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.10/24 brd 192.168.10.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever

Something was probably wrong in my last test as I said the server showed the old ip address it had, it does this every now and then when I restart the ap.

19
  • ip addr, ip route, ping command outputs
    – gapsf
    Sep 26, 2022 at 19:19
  • yes @gapsf as you requested above!
    – Snakehater
    Sep 26, 2022 at 19:55
  • On server pov there is no ipv4 addresses configured on interfaces, obviously so ip wont work assign ip for wlan0 at least
    – gapsf
    Sep 26, 2022 at 19:58
  • Alright @gapsf makes sense, how can I configure that?
    – Snakehater
    Sep 26, 2022 at 20:08
  • What os on pov is installed
    – gapsf
    Sep 26, 2022 at 20:12

1 Answer 1

0

In case anybody encounters this in the future, running following commands after starting the AP and dhcp server did the job:

ifconfig wlan0 192.168.2.1 netmask 255.255.255.0 up
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1

This is because I needed to setup an IP address for the wlan0 interface, and then route it to the network. That way the rpi is connected to the network since all of the network requests gets routed to the right address.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .