pages tagged gargoyleFeeding the Cloudhttps://feeding.cloud.geek.nz/tags/gargoyle/Feeding the Cloudikiwiki2022-07-02T02:45:10ZUsing all of the 5 GHz WiFi frequencies in a Gargoyle Routerhttps://feeding.cloud.geek.nz/posts/using-all-5ghz-wifi-frequencies-in-gargoyle-router/
<a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
2021-06-11T20:43:57Z2017-12-11T02:00:00Z
<p>WiFi in the 2.4 GHz range is usually fairly congested in urban environments.
The 5 GHz band used to be better, but an increasing number of routers now
support it and so it has become fairly busy as well. It turns out that there
are a
<a href="https://en.wikipedia.org/wiki/List_of_WLAN_channels#5_GHz_.28802.11a.2Fh.2Fj.2Fn.2Fac.29">number of channels on that band</a>
that nobody appears to be using despite being legal in my region.</p>
<h2 id="Why_are_the_middle_channels_unused.3F">Why are the middle channels unused?</h2>
<p>I'm not entirely sure why these channels are completely empty in my area,
but I would speculate that access point manufacturers don't want to deal
with the extra complexity of the middle channels. Indeed these channels are
not entirely unlicensed. They are also used by weather radars, for example.
If you look at the regulatory rules that ship with your OS:</p>
<pre><code>$ iw reg get
global
country CA: DFS-FCC
(2402 - 2472 @ 40), (N/A, 30), (N/A)
(5170 - 5250 @ 80), (N/A, 17), (N/A), AUTO-BW
(5250 - 5330 @ 80), (N/A, 24), (0 ms), DFS, AUTO-BW
(5490 - 5600 @ 80), (N/A, 24), (0 ms), DFS
(5650 - 5730 @ 80), (N/A, 24), (0 ms), DFS
(5735 - 5835 @ 80), (N/A, 30), (N/A)
</code></pre>
<p>you will see that these channels are flagged with "DFS". That stands for
<a href="http://wifi-insider.com/wlan/dfs.htm">Dynamic Frequency Selection</a> and it
means that WiFi equipment needs to be able to detect when the frequency is
used by radars (by detecting their pulses) and automaticaly switch to a
different channel for a few minutes.</p>
<p>So an access point needs extra hardware and extra code to avoid interfering
with priority users. Additionally, different channels have
<a href="http://www.radio-electronics.com/info/wireless/wi-fi/80211-channels-number-frequencies-bandwidth.php">different bandwidth limits</a>
so that's something else to consider if you want to use 40/80 MHz at once.</p>
<h2 id="Using_all_legal_channels_in_Gargoyle">Using all legal channels in Gargoyle</h2>
<p>The first time I tried setting my access point channel to one of the middle
5 GHz channels, the SSID wouldn't show up in scans and the channel was still
empty in <a href="https://f-droid.org/packages/com.vrem.wifianalyzer/">WiFi Analyzer</a>.</p>
<p>I tried changing the channel again, but this time, I ssh'd into my router
and looked at the errors messages using this command:</p>
<pre><code>logread -f
</code></pre>
<p>I found a number of errors claiming that these channels were not authorized
for the "world" regulatory authority.</p>
<p>Because <a href="https://www.gargoyle-router.com/">Gargoyle</a> is based on
<a href="https://openwrt.org/">OpenWRT</a>, there are a lot more
<a href="https://wiki.openwrt.org/doc/uci/wireless">wireless configuration options</a>
available than what's exposed in the Web UI.</p>
<p>In this case, the solution was to explicitly <a href="https://feeding.cloud.geek.nz/posts/setting-wifi-regulatory-domain-linux-openwrt/">set my country in the wireless options</a> (where <code>CA</code> is the
<a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">country code</a> for Canada, where my
router is physically located).</p>
<p>Then I rebooted and I was able to set the channel successfully via the Web UI.</p>
<p>If you are interested, there is a lot more information about how all of this
works in the
<a href="https://wireless.wiki.kernel.org/en/developers/regulatory/processing_rules#country_definition">kernel documentation for the wireless stack</a>.</p>
Setting the wifi regulatory domain on Linux and OpenWRThttps://feeding.cloud.geek.nz/posts/setting-wifi-regulatory-domain-linux-openwrt/
<a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
2021-06-11T20:43:57Z2015-08-01T20:20:00Z
<p>The list of <a href="https://en.wikipedia.org/wiki/List_of_WLAN_channels">available wifi channels</a>
is slightly different from country to country. To ensure access to the
right channels and transmit power settings, one needs to set the right
regulatory domain in the wifi stack.</p>
<h1 id="Linux">Linux</h1>
<p>For most Linux-based computers, you can look and change the current
regulatory domain using these commands:</p>
<pre><code>iw reg get
iw reg set CA
</code></pre>
<p>where <em><code>CA</code></em> is the <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">two-letter country code</a>
when the device is located.</p>
<p>On Debian and Ubuntu, you can make this setting permanent by putting the
country code in <code>/etc/default/crda</code>.</p>
<p>Finally, to see the list of channels that are available in the current
config, use:</p>
<pre><code>iwlist wlan0 frequency
</code></pre>
<h1 id="OpenWRT">OpenWRT</h1>
<p>On <a href="https://openwrt.org/">OpenWRT</a>-based routers (including derivatives like
<a href="https://www.gargoyle-router.com/">Gargoyle</a>), looking and setting the
regulatory domain temporarily works the same way (i.e. the <code>iw</code> commands
above).</p>
<p>In order to persist your changes though, you need to use the
<a href="http://wiki.openwrt.org/doc/uci/wireless">uci</a> command:</p>
<pre><code>uci set wireless.radio0.country=CA
uci set wireless.radio1.country=CA
uci commit wireless
</code></pre>
<p>where <em><code>wireless.radio0</code></em> and <em><code>wireless.radio1</code></em> are the wireless devices
specific to your router. You can look them up using:</p>
<pre><code>uci show wireless
</code></pre>
<p>To test that it worked, simply reboot the router and then look at the
selected regulatory domain:</p>
<pre><code>iw reg get
</code></pre>
<h1 id="Scanning_the_local_wifi_environment">Scanning the local wifi environment</h1>
<p>Once your devices are set to the right country, you should scan the local
environment to pick the least congested wifi channel. You can use the
<a href="https://kismetwireless.net/spectools/">Kismet spectools</a>
if you have the hardware, otherwise
<a href="https://f-droid.org/repository/browse/?fdid=com.vrem.wifianalyzer">WiFi Analyzer</a>
is a good choice on Android.</p>
Debugging OpenWRT routers by shipping logs to a remote syslog serverhttps://feeding.cloud.geek.nz/posts/debugging-openwrt-routers-by-shipping/
<a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
2022-07-02T02:45:10Z2012-01-14T08:45:00Z
<p>Trying to debug problems with consumer-grade routers is notoriously difficult due to a lack of decent debugging information. It's quite hard to know what's going on without at least a few good error messages.</p>
<p>Here is how I made my <a href="https://openwrt.org/">OpenWRT</a>-based <a href="http://gargoyle-router.org/">Gargoyle</a> router send its log messages to a network server running <a href="http://rsyslog.com/">rsyslog</a>.</p>
<h3 id="Server_Configuration">Server Configuration</h3>
<p>Given that the router (<code>192.168.1.1</code>) will be sending its log messages on UDP port 514, I started by opening that port in my firewall:</p>
<pre><code>iptables -A INPUT -s 192.168.1.1 -p udp --dport 514 -j ACCEPT
</code></pre>
<p>Then I enabled the UDP module for rsyslog and redirected messages to a separate log file (so that it doesn't fill up <code>/var/log/syslog</code>) by putting the following (a modified version of <a href="http://rsyslog.com/storing-messages-from-a-remote-system-into-a-specific-file/">these instructions</a>) in <code>/etc/rsyslog.d/10-gargoyle-router.conf</code>:</p>
<pre><code>$ModLoad imudp
$UDPServerRun 514
:fromhost-ip, isequal, "192.168.1.1" /var/log/gargoyle-router.log
& ~
</code></pre>
<p>The name of the file is important because this configuration snipet needs to be loaded before the directive which writes to <code>/var/log/syslog</code> for the discard statement (the "& ~" line) to <a href="http://lists.adiscon.net/pipermail/rsyslog/2012-January/014201.html">work correctly</a>.</p>
<h3 id="Router_Configuration">Router Configuration</h3>
<p>Finally, I followed the <a href="http://www.gargoyle-router.com/wiki/doku.php?id=remote_syslog">instructions</a> on the Gargoyle wiki to get the router to forward its log messages to my server (<code>192.168.1.2</code>).</p>
<p>After logging into the router via ssh, I ran the following commands:</p>
<pre><code>uci set system.@system[0].log_ip=192.168.1.2
uci set system.@system[0].cronloglevel=7
uci commit
</code></pre>
<p>before rebooting the router.</p>
<p>Now whenever I have to troubleshoot network problems, I can keep a terminal open on my server and get some visibility on what the router is doing:</p>
<pre><code>tail -f /var/log/gargoyle-router.log
</code></pre>