How to force hostapd to create a 40MHz bandwidth channel

Hostapd is a user space daemon software enabling a network interface card to act as an access point and authentication server. Hence that we can utilize this software to build a private AP. IEEE802.11n protocol is capible to build a 20 MHz or 40 MHz channel. However, hostapd automatically swich the 40 MHz to 20MHz if there are interferences in environment. In morden city, it is impossible to live in an environment without other WiFi surronding by. For this reason channels are always 20 MHz

In this blog, I would like to share my experience in forcing hostapd to run on 40 MHz no matter whether there has interferences or not. Here, I would like to show my thanks to LateLee link. His work is wonderful and the content of this blog is actually based on that. However, since LateLee is an experienced expert, it is very hard for a rookie to fully understand his blog (At least for me). So this blog will give more explainations as a detailed menu.

DOWNLOAD HOSTAPD SOURCE CODE

All the patches must be moved to the hostapd source code. Here I post this link to help you guys to download the already adjusted version of hostapd shared on github by LateLee. By downloading this version of source code there is no need to make any adjustment in source code anymore, indeed convenient.

1. Unzip the downloaded code packet.
2. cd …/hostapd-master/hostapd (Linux loop knowledge required)
3. cp defconfig .config (create a config file for make process)
4. sudo gedit .config (make some adjustments in config file)
5. in .config, uncomment two lines: CONFIG_DRIVER_NL80211=Y CONFIG_IEEE80211N=y
6. sudo apt-get install libnl-dev
7. sudo apt-get install libssl-dev
8. make (finally we run make command to compile the hostapd source code. If there are errors, that means you make some errors in steps 3-7)
9. make install (Burn the compiled hostapd module into Linux system)

Following these 9 steps, you have successfully installed hostapd in system from source code. Be alert, if you run the command: sudo apt-get install hostapd, of course you can install hostapd too but sadly it is very hard to find its source code (quite annoying).

EDIT HOSTAPD.CONF

This is also a very important step, becuase the hostapd.conf file defines how will the hostapd work. If it is not programmed well, you still cannot run 40 MHz even with adjusted hostapd source code. In LateLee’s blog, he did not give an example, extremely unfriendly for rookies. So here I will show my example and explain how the check the real channel bandwidth of your AP.

1. cd Desktop/ (I woud liek to create the conf file on desktop)
2. sudo gedit hostapd.conf (this command creates a new file called hostapd.conf)
3. copy and paste: Be alert, remember to remove my comment
interface=wlan0

driver=nl80211
ssid=test
country_code=US
hw_mode=g
channel=1
preamble=1
macaddr_acl=0

auth_algs=1
logger_syslog=-1
logger_syslog_level=3
logger_stdout=-1
logger_stdout_level=2
ignore_broadcast_ssid=0
force_40mhz=1 #// THIS IS THE MOST IMPORTANT COMMAND. Actually this command is created by LateLee,
              #// its function is to force AP use 40MHz channel.
ieee80211n=1
#// Since we are using channel 1, in order to enable 40MHz, the following command
#// is necessary.You can learn more details in hostapd manual.
ht_capab=[HT40+][SHORT-GI-20][SHORT-GI-40]
wmm_enabled=1
4. after saving your conf file, now it is time to run the hostapd to test effectiveness.
5. sudo hostapd -d Desktop/hostapd.conf (-d here means showing details)
6. if there are errors showing that AP cannot work, do the followings:
  1. sudo nmcli nm wifi off
  2. sudo rfkill unblock wlan
  3. sudo killall hostapd
  4. service hostapd start
7. after successfully run hostapd, in the working log you should find the following content:


Found overlapping 20 MHz HT BSS: 24:f5:a2:aa:dd:74 freq=2427
Overlapping 20 MHz BSS is found
But will force to 40MHz due to force_40mhz.
HT40: control channel: 1 secondary channel: 5

Completing interface initialization
Mode: IEEE 802.11g Channel: 1 Frequency: 2412 MHz
DFS 0 channels required radar detection
nl80211: Set freq 2412 (ht_enabled=1, vht_enabled=0, bandwidth=40 MHz, cf1=2422 MHz, cf2=0 MHz)

if you use normal hostapd to do the same thing, the related content will be:
#hostapd -d /etc/hostapd/hostapd.conf

40 MHz affected channel range: [2407,2457] MHz
Neighboring BSS: 00:19:cb:a1:68:82 freq=2412 pri=0 sec=0
Neighboring BSS: 9c:c7:a6:ea:2f:7f freq=2412 pri=1 sec=0
Neighboring BSS: 88:25:2c:ac:0d:3c freq=2412 pri=1 sec=5
40 MHz pri/sec mismatch with BSS 88:25:2c:ac:0d:3c <2412,2432> (chan=1+) vs. <2442,2422>
20/40 MHz operation not permitted on channel pri=7 sec=3 based on overlapping BSSes

Conclusions

In this blog I shared my experience in forcing hostapd to run on 40MHz. However, I did not discuss the chages in source code. If you are interested, please have a look at LateLee’s valuable blog. After all, the ability of making changes in source codes is one of the most charming things in Linux system. Yeah, it’s indeed difficult and hard to catch up, but this is it.

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值