HostAPD - can't connect to the Internet or ping other devices

Hi!
I'm trying to setup an AP (wired to wireless) on FreeBSD 13.0-RELEASE. As I'm a complete noob on FreeBSD, I tried to follow some guides on the Internet, without success.
The AP is already up and running and I connected my phone to it. The problem is that I can't ping devices inside my network and I don't have internet access. Could anybody help me?
Thanks for your time!
 
You need to enable routing; gateway_enable="YES" in /etc/rc.conf. Or else the machine will be a single "end-point" host and not route traffic between interfaces (which is what you're trying to do here).
 
Can't do much with "it doesn't work". Time to learn how to use tcpdump(1) and actually look at the traffic coming in on the one interface and out the other.

The AP is already up and running and I connected my phone to it. The problem is that I can't ping devices inside my network and I don't have internet access.
So, here's my guess based on the little amount of information. Your wireless connection actually works fine. Routing on the AP works fine too. But your ISP's modem/router has no way of knowing what network is behind the AP, thus it doesn't know where to send the replies back to.

If you have set up your network with one subnet for your wired network and one subnet for your wireless, your ISP modem/router will need a static route. It needs to know where it can find that subnet that's used on the wireless part of the network.
 
Hi!
I'm sorry for my lack of clarity but I don't really know what I can give you for you guys to be able to help me. I assume I'm quite nervous because I thought this would be easier...
Here's part of my /etc/rc.conf:
Code:
hostname="vmtHP"
ifconfig_re0="inet 192.168.1.110 netmask 255.255.255.0"
defaultrouter="192.168.1.254"

wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap"
hostapd_enable="YES"
ifconfig_wlan0="inet 192.168.1.110 netmask 255.255.255.0"
gateway_enable="YES"

pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""

Here's my /etc/pf.conf
Code:
lan_if="eth0"
wifi_if="wlan0"
set block-policy return
set skip on lo
nat on $lan_if from $wifi_if:network to any -> ($lan_if)
block in log all
pass out log quick
pass in log on $wifi_if inet
pass in log on $lan_if inet
pass out log inet proto icmp from any to any keep state
pass in log quick inet proto icmp from any to any keep state

I believe what you said is correct. The router can't detect the devices connected to the hotspot. I ran tcpdump(1) and I could see that the device connected was sending packets to different IPs, with no response. I also saw many ARP packets:
Code:
22:49:11:775231 ARP, Request who-has 192.168.1.254 tell 192.168.1.154, length 28
There's probably some flaws and errors in those files. I was wondering if you could help me as I have no experience in this.

Thanks for your time!
 
I am asking about your network because you should consider a dhcp server.
Let it manage your addresses. ICS or dnsmasq

Do you use an upstream box/router ? Where are your addresses assigned from? Do you have a static IP network?
 
Ideally your setup would use re0 as your WAN or uplink port. Set to use DHCP as client if you have an upstream box.
WLAN0 is setup to distribute addresses via a dhcp server. Either locally or upstream via bridging.

Here is my real understanding FreeBSD Wireless Access Point post.
Chris really pushed me to understand what all the settings meant.
Good exercise. I had hostAP running by tutorials and he helped me hone my knowledge.
Please note that this is an hostapd box behind a firewall. So my pf usage here is NAT only.

I have since messed with bridges as well. Good for keeping a single address range.
That's all I have to say good about bridges..
 
This is throwing a flag for me.

defaultrouter="192.168.1.254"
Upon Google search it seems lots of tutorials point to this setting. It uses the default route.
I prefer to point to the actual upstream box IP. Like 192.168.1.1 on class C network.
Nowhere in FreeBSD documentation do you see the use of 192.168.1.254 as default router.
The default route can defined in /etc/rc.conf by specifying the IP address of the default gateway

Why set default_router to the default route with 192.168.1.254? What if default route is wrong?.
Point to a physical gateway is my suggestion.
 
Hi!
Thanks for helping out!
Firstly just want to say: I know it's weird but my physical gateway is 192.168.1.254.
I've changed the
ifconfig_wlan0="inet 192.168.1.110 netmask 255.255.255.0"
for
Code:
ifconfig_wlan0="inet 192.168.1.150 netmask 255.255.255.0"
The computer is directly connected to the router through the ethernet port (et0 interface) I'm running a Plex server and it's running perfectly fine.
I want the main router to serve as the DHCP server. I don't know if that's possible. Even if it isn't, I put a static IP on my phone (192.168.1.154) with the physical gateway (192.168.1.254), so it should work, right?
This boils down to wide open. Is that what you meant to do?
I wanted to just get it working without messing around too much. That's why I still didn't activate IPv6 or DHCP (as the guide I was following suggested). I'm looking forward to bring those features but for now I just want to get it working...
Thanks for your time!
 
Nowhere in FreeBSD documentation do you see the use of 192.168.1.254 as default router.
It's not that uncommon to have the last IP addresses, instead of the first, of a subnet as a gateway. It doesn't really matter which IP address you use as long as things are set up properly. Most people use the first couple of addresses for gateways but this isn't a strict rule.

Code:
% grep defaultrouter /etc/rc.conf
defaultrouter="172.21.40.254"

The same IP address (and network subnet) on two different interfaces is very wrong though.

That's why I still didn't activate IPv6 or DHCP (as the guide I was following suggested).
In order to run a DHCP service on those interfaces you're going to need a static IP address for the DHCP service anyway. So there's nothing wrong with using static addresses here. But you fail to understand the basics of subnetting and routing. That's where you're heading in the wrong direction.
 
It's not that uncommon to have the last IP addresses, instead of the first, of a subnet as a gateway. It doesn't really matter which IP address you use as long as things are set up properly. Most people use the first couple of addresses for gateways but this isn't a strict rule.

Code:
% grep defaultrouter /etc/rc.conf
defaultrouter="172.21.40.254"

The same IP address (and network subnet) on two different interfaces is very wrong though.


In order to run a DHCP service on those interfaces you're going to need a static IP address for the DHCP service anyway. So there's nothing wrong with using static addresses here. But you fail to understand the basics of subnetting and routing. That's where you're heading in the wrong direction.
Hi!
Thanks for helping out! I'm sorry for my lack of knowledge. But I'm always looking forward to learning new stuff!

I installed isc-dhcp44-server-4.4.2P1_1 server as the guide I was following suggested.
I also noticed a mistake on the files I sent.
lan_if="eth0"
The interface eth0 doesn't exist. Instead, I have the interface re0 as my ethernet card.

I also decided to run dmesg() and saw this message coming from the dhcp server:
Code:
Multiple interfaces match the same subnet: re0 wlan0
Multiple interfaces match the same shared network: re0 wlan0
Maybe with these messages you can guess what I did wrong?
Thanks for your time!
 
Hi!
Thanks for your help!
You have two interfaces pointing at one IP.
That will never work.
I had already changed that and it still didn't work...
I've changed the ifconfig_wlan0="inet 192.168.1.110 netmask 255.255.255.0"
for
ifconfig_wlan0="inet 192.168.1.150 netmask 255.255.255.0"
Maybe my files are not written properly... The thing is that I can't identify the mistakes...
 
Maybe my files are not written properly... The thing is that I can't identify the mistakes...
These are both still on the same subnet (192.168.1.x). You can't route traffic to and from the same subnet, it makes no sense.

You have to either use a different subnet for the wireless side or create a bridge:
 
These are both still on the same subnet (192.168.1.x). You can't route traffic to and from the same subnet, it makes no sense.

You have to either use a different subnet for the wireless side or create a bridge:
Hi!
Thanks for your explanation! I feel like a baby between you guys but it FINALLY WORKS! I can now see that I have a lot to learn about networking!
The only problem now is that I'm having loads of packet loss on my phone: 8/20 (60%) for 192.168.1.254 and 13/20 (35%) for google.com. Is there any way to make it better?
Thanks a lot for your help!
 
Is there any way to make it better?
First do a site survey. Determine holes in channel coverage. Host your AP on best channel.
Determine if range or speed is more important to you. 5Ghz for range and 2.4 for Speed.
2.4 is clogged so you lose most speed advantage of the lower frequency range.
So look at 5ghz if client hardware allows. Probe channels for gaps from neighboring wireless hardware.
802.11na is best with an open three channel span for best results.
Also checkout HT settings.
For 802.11na there's 20, 40, and 80MHz wide channels - this is a lot of combinations.
There is a nice chart to help figure out the grouping.
The blocks around channel grouping is an important feature.
 
That was my WAP optimization tips.
With the packet loss you cite something else is still not set right.
What distance from WAP to phone?
Have you tried pinging from WAP to google? Not phone to google?
See where your issue lays.
 
Back
Top