Hostapd for realtek 8811cu. Needs patched hostapd

==============================================
Wi-Fi drivers used:

https://github.com/morrownr/8821cu-20210118

Instructions used for patched realtek compatible hostapd:

The instructions seem different than what I remember following, or maybe they’re in a different place, but here’s the link the readme gives:

GitHub - pritambaral/hostapd-rtl871xdrv: Hostapd driver for RTL8188{C|CU|CUS} wifi chips.

I desparately want to pi-hole the smarr tvs in my home to cut out all the unnecessary junk loading but still allow the device to be used.

E-waste should not exist. I have a very, very old 64-bit machine with just under a gig of ram (mismatched sticks, I had 1.5+ G but either sticks failed or I placed them elsewhere, not with me.)

I want to just run Debian because I got the drivers working in a VM. The issue is, I would have to run one hell of a complicated firewall setup, making that a no-go, or resort to figuring out how to use hostapd.

The issue is, I can’t use the drivers that I have installed to do this (I think, who knows) but either way, I can’t just setup hostapd because the realtek drivers that I use (maybe) uses some different version of something that hostapd no longer uses.

So I try as I might and I DO get hostapd patched–except now I have to copy those patched files (which I cannot find) and copy them to the hostapd foldee.

Then, I can install hoatapd. And that’s just tp get it installed.

Once I get that far, however long that will take, I’ll definitely nesd some serious assistance setting up, no experience at all with it.

I want to get this thread started and will update with the exact driver I’m using, exactly the instructions I’m following, and exactly where I’m stumped on the file copying.

Hope you all can help. I did have the opportunity to use a wifi router with its own built in firmware, would be really cool if usb wireless cards had built in stuff so it doesn’t need drivers.

I got (most of) the files patched with at least one exception:

Look at the "driver.h" file.  I'd imagine that's an important file to patch to make all of this work, and it's the ONE file that fails to patch.  Just my luck.  Here's the output:

 patch -p1 -i '/home/username/RTL2/hostapd-rtl871xdrv/rtlxdrv.patch' 
patching file hostapd/main.c
Hunk #1 succeeded at 412 with fuzz 1 (offset -36 lines).
patching file src/ap/beacon.c
Hunk #1 succeeded at 810 with fuzz 1 (offset -316 lines).
patching file src/ap/hw_features.c
Hunk #1 succeeded at 712 (offset 216 lines).
**patching file src/drivers/driver.h**
**Hunk #1 FAILED at 4984.**
**1 out of 1 hunk FAILED -- saving rejects to file src/drivers/driver.h.rej**
patching file src/drivers/driver_bsd.c
Hunk #1 succeeded at 47 with fuzz 2 (offset -9 lines).
Hunk #2 succeeded at 798 (offset -54 lines).
Hunk #3 succeeded at 1140 with fuzz 2 (offset -43 lines).
Hunk #4 succeeded at 1571 with fuzz 1 (offset -61 lines).
Hunk #5 succeeded at 1905 with fuzz 2 (offset -125 lines).
Hunk #6 succeeded at 1985 (offset -127 lines).
patching file src/drivers/driver_rtl.h
patching file src/drivers/driver_rtw.c
patching file src/drivers/driver_wext.c
Hunk #1 succeeded at 990 (offset -91 lines).
Hunk #2 succeeded at 1044 (offset -91 lines).
patching file src/drivers/drivers.c
Hunk #1 succeeded at 94 (offset 48 lines).
patching file src/drivers/drivers.mak
Hunk #1 succeeded at 58 (offset -21 lines).
Hunk #2 succeeded at 78 with fuzz 1 (offset -15 lines).
patching file src/eap_peer/eap_wsc.c
Hunk #1 succeeded at 566 (offset 1 line).
patching file src/wps/wps.c
Hunk #1 succeeded at 320 (offset -5 lines).
Hunk #2 succeeded at 345 (offset -5 lines).
patching file src/wps/wps_registrar.c

Anyway, I am having trouble “make”-ing the hostapd after running the patch.

Here is the output, maybe someone is having the same issue or understands how to solve it:

``
@username$ :~/RTL2/hostapd-2.2/hostapd$ make
Building hostapd requires a configuration file
(.config). See README for more instructions. You can
run “cp defconfig .config” to create an example
configuration.
make: *** [Makefile:896: verify_config] Error 1
@username$ :~/RTL2/hostapd-2.2/hostapd$ make
CC main.c
CC config_file.c
CC …/src/ap/hostapd.c
CC …/src/ap/wpa_auth_glue.c
CC …/src/ap/drv_callbacks.c
CC …/src/ap/ap_drv_ops.c
CC …/src/ap/utils.c
CC …/src/ap/authsrv.c
CC …/src/ap/ieee802_1x.c
CC …/src/ap/ap_config.c
CC …/src/ap/eap_user_db.c
CC …/src/ap/ieee802_11_auth.c
CC …/src/ap/sta_info.c
CC …/src/ap/wpa_auth.c
CC …/src/ap/tkip_countermeasures.c
CC …/src/ap/ap_mlme.c
CC …/src/ap/wpa_auth_ie.c
CC …/src/ap/preauth_auth.c
CC …/src/ap/pmksa_cache_auth.c
CC …/src/ap/ieee802_11_shared.c
CC …/src/ap/beacon.c
…/src/drivers/drivers.c:98:3: error: ‘wpa_driver_rtw_ops’ undeclared here (not in a function); did you mean ‘wpa_driver_ops’?
98 | &wpa_driver_rtw_ops,
| ^~~~~~~~~~~~~~~~~~
| wpa_driver_ops
make: *** [Makefile:891: …/src/drivers/drivers.o] Error 1
@username$ :~/RTL2/hostapd-2.2/hostapd$

I left out where exactly to get this stuff, here’s the link to the command to the git repository and install this for anyone who wants to test it.

git clone https://github.com/pritambaral/hostapd-rtl871xdrv.git

So I am out of ideas.

Is the USB NIC not at all detected?
Or detected, but not working?
If working, does it work as a client, just not as an access point?

I had a realtek USB dongle that would not work as a AP, but I got drivers off github, which specifically said did Not work as an AP< but there is one wi-fi channel that it Did work for, so I did get to. (my model was different, 88x2bu style)

So how far did you get?

Just in case the dongle works as a dongle and the trouble was the ap side…

Yeah, AP side. Otherwise, drivers seem to work fine. I just can’t get this hostapd junk figured out. This is why Windows is used on 98% of desktops world-wide. If we could make these things simpler, I think windows usage would drop quite a bit.

I might try just setting up debian again, reinstalling the drivers, again, and then try a version of hostapd that’s hopefully already patched. I bet that’ll be another post about some error, I’ll keep at it. I could solve this whole situation with just a 50 ft. usb cable and just run the setup that I have, but I don’t have one.

1 Like

Fair play man.

For me, I did need the drivers to get the dongle to work, but standard hostapd followed this git to set up hostap.

Sepperately played with wpa_supplicant, but went back to hostap. then just moved to a physical router I had spare

If it helps, I have notes of 4 steps I took-

1. Install Drivers

from
GitHub - morrownr/88x2bu-20210702: Linux Driver for USB WiFi Adapters that are based on the RTL8812BU and RTL8822BU Chipsets - v5.13.1

sudo apt install -y dkms git build-essential

mkdir -p ~/src && cd ~/src

git clone GitHub - morrownr/88x2bu-20210702: Linux Driver for USB WiFi Adapters that are based on the RTL8812BU and RTL8822BU Chipsets - v5.13.1

cd ~/src/88x2bu-20210702

./cmode-on.sh

sudo ./install-driver.sh

sudo ./edit-options.sh

reboot server

2. Assign IP addresses to NIC's

#setting IP for wired, and wireless NIC’s

root@ubuifi108:/etc/systemd/network# cat 01-wired-trooper-ishnet.network

[Match]
Name=ens18

[Network]
Address=10.10.100.108/24
Gateway=10.10.100.130
DNS=10.10.100.242
DNS=10.10.100.102
DNS=9.9.9.10
DHCP=false

root@ubuifi108:/etc/systemd/network# cat 02-wifi-trooper-ishnet.network

[Match]
Name=wlxe848b8900fb8

[Network]
DHCP=false
DHCPServer=yes
DNS=10.10.100.102
IPForward=ipv4
IPMasquerade=ipv4
IPMasquerade=true
# IPMasquerade is doing NAT

[Address]
Address=10.10.200.108/24
[DHCPServer]
PoolOffset=50
PoolSize=20
EmitDNS=yes
DNS=10.10.100.130
DNS=9.9.9.10
3. Forward IP Traffic

Internet sharing - ArchWiki

#1# iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE
#2# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
#3# iptables -A FORWARD -i wlxe848b8900fb8 -o ens18 -j ACCEPT

#iptables-save -f /etc/iptables.rules

###make systemd unit
#nano /etc/systemd/system/restore-iptables-rules.service

[Unit]
Description = Apply iptables rules

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'iptables-restore < /etc/iptables.rules'

[Install]
WantedBy=network-pre.target

#sudo systemctl enable restore-iptables-rules.service

4. HostAPd setup

Setup Ubuntu server as Access point · GitHub

sudo apt-get install hostapd

write a new config file for hostapd sudo nano /etc/hostapd/hostapd.conf

interface=wlxe848b8900fb8
driver=nl80211
ssid=wifiapccesspointname  
hw_mode=g
channel=8
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=supersecretpassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

edit /etc/default/hostapd and change the line starts with #DAEMON_CONF, remembering to remove #

DAEMON_CONF="/etc/hostapd/hostapd.conf"

sudo iw reg get frequency for channels

used 8, seemed to work

# Setup the interface

#$ ip link set wlxe848b8900fb8 down
#$ ip addr flush dev wlxe848b8900fb8
#$ ip link set wlxe848b8900fb8 up
#$ ip addr add 10.10.200.108 dev wlxe848b8900fb8
$ sudo systemctl enable hostapd && sudo systemctl start hostapd

If step 4 helps, great. Otherwise, sorry to spam your thread.

I’m using my pick for now.

dpkg-buildpackage: info: source package hostapd-rtl
dpkg-buildpackage: info: source version 2.4-4
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Jeka Der <[email protected]>
 dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
dpkg-checkbuilddeps: error: Unmet build dependencies: **libnl-dev**
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui failed

So, how do I get that dependency on Debian 11?

Is that the base package of hostapd on Debian?

I guess I personally would not flog that horse, perhaps look at wpa_supplicant? but, perhaps our devices are more different.

I presumed the app would build, with the version from official repo’s, then fail to grab the device needed on runtime.

but if even the official package does not build, there may be deep er issues?

This is the build script for a rtl patched version of hostapd. I’ve tried two different things, I can’t remembee exactly how it all fit together exactly, but I would like to get that depemdency to at least know if this method will work.

There is a package libnl-2-dev in some repo’s, looks like my base OS has libnl-3-200 installed.
I’d suggest give sudo apt search libnl a go, and see if it comes up with any hits? my results are:

compressed
trooper-ish@Ubu2004RedChungus:~$ sudo apt search libnl
Sorting... Done
Full Text Search... Done
libnl-3-200/jammy,now 3.5.0-0.1 amd64 [installed,automatic]
  library for dealing with netlink sockets

libnl-3-200-dbg/jammy 3.5.0-0.1 amd64
  debug symbols for libnl3

libnl-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-3

libnl-cli-3-200/jammy 3.5.0-0.1 amd64
  library for dealing with netlink sockets - cli helpers

libnl-cli-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-cli-3

libnl-genl-3-200/jammy,now 3.5.0-0.1 amd64 [installed,automatic]
  library for dealing with netlink sockets - generic netlink

libnl-genl-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-genl-3

libnl-idiag-3-200/jammy 3.5.0-0.1 amd64
  library for dealing with netlink sockets - inetdiag interface

libnl-idiag-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-genl-3

libnl-nf-3-200/jammy 3.5.0-0.1 amd64
  library for dealing with netlink sockets - netfilter interface

libnl-nf-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-nf-3

libnl-route-3-200/jammy,now 3.5.0-0.1 amd64 [installed,automatic]
  library for dealing with netlink sockets - route interface

libnl-route-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-route-3

libnl-utils/jammy 3.5.0-0.1 amd64
  Utilities for dealing with netlink sockets

libnl-xfrm-3-200/jammy 3.5.0-0.1 amd64
  library for dealing with netlink sockets - package transformations

libnl-xfrm-3-dev/jammy 3.5.0-0.1 amd64
  development library and headers for libnl-xfrm-3

libnlopt-cxx-dev/jammy 2.7.1-3build1 amd64
  nonlinear optimization library -- development package for C++

libnlopt-cxx0/jammy 2.7.1-3build1 amd64
  nonlinear optimization library (C++ interface)

libnlopt-dev/jammy 2.7.1-3build1 amd64
  nonlinear optimization library -- development package

libnlopt-guile0/jammy 2.7.1-3build1 amd64
  nonlinear optimization library -- Guile bindings

libnlopt0/jammy 2.7.1-3build1 amd64
  nonlinear optimization library

so there are a bunch of versions.
if none are installed, give one a go.
if some are installed, maybe look at the dev versions?

the script looks for the name exactly. I doubt renaming would work and it’s not in debian 11 repo.

Looks like the origional package was depreciated back in 2014.

Perhaps amending the call to a current version might do the trick?
You might even have a current version installed already

Yeah, I figured this would be aggravating. But it’s the hardware that I have. I’m going to start over this thread, because I’m on bare-metal vs a VM now (I wanted to figure it out in a VM, but I got eager and wanted to setup Linux with working wi-fi) and I can’t remember how I got to patching hostapd in the first place. I’m going to start over and make a new thread. I can’t remember how I followed the directions, and I need others that know more about this than I do to guide this process.

2 Likes