By connecting Raspberry Pi as a Wi-Fi repeater to mobile Wi-Fi, which has a limited number of connections, and adding a new Wi-Fi network, the shortage of Wi-Fi connections in the home was solved. During the setting, I encountered a problem that the fixed IP could not be set, so I will show you the solution.
Recently, I changed my home internet environment to mobile Wi-Fi. The communication speed is also reasonable, and you can watch Amazon Video comfortably. However, the maximum number of connections is 5 and it is small. There is no problem if you only have a smartphone and a PC, but it is not enough if you connect Google Home etc. It's a waste to buy a new Wi-Fi repeater. It takes some time to select a repeater. Additional Wi-Fi connections are available for Google Home, Nature Remo, and printers. The communication distance may be delivered in one room. As for the communication speed, you can listen to music. Considering the location and communication speed when using Raspberry Pi wirelessly, it seems that there is no problem.
So, I tried to make Raspberry Pi a Wi-Fi repeater. (Here, "repeater" is described as adding a new wireless network, not expanding the communication distance within the same network.)
Raspberry Pi 4 Model B Raspbian Buster
Wi-Fi dongle PLANEX GW-USNano2
Earlier, when I tried the same thing, it failed, so I checked multiple sites to understand to some extent.
Raspberry Pi 3 + USB WiFi dongle, Wi-Fi repeater --Qiita [Note] Wi-Fi access point router on Raspberry Pi 3-Qiita Capture packets by relaying wireless LAN with mitmproxy on Raspberry Pi | Maple Rice's Blog How to make a WiFi local server using Raspberry Pi-Qiita Wireless LAN access point with Raspberry Pi – Greenleaf Turn Raspberry Pi into a WiFi access point! [Making WiFi of Raspberry Pi 3 Model B into a wireless LAN access point and making it a WiFi router hostapd + bridge-utils (How to set up the communication environment by using the WiFi built into Raspberry Pi 3 as a wireless LAN access point)](http: / /www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_3_wifi_wireless_access_point/) Making WiFi of Raspberry Pi 3 into a wireless LAN access point with ad blocking function hostapd + dnsmasq edition (How to make WiFi built into Raspberry Pi 3 a high-performance router with ad blocking function (with ad + fraud + adult blocking function) ) Access Point | goozenlab
There is a lot of information, but old information is also confused. You also need to search for the Raspbian version (Buster). At first glance, the functions introduced in each article are the following four points.
--hostapd access point --isc-dhcp-server DHCP server --dnsmasq DNS server and DHCP server --bridge-utils Bridge settings
This time, there is a limit to the number of original mobile Wi-Fi connections, so that routing function cannot be used. In order to increase the number of connections, I decided to create a new network with Raspberry Pi and route it. That is, it does not bridge. Also, I feel that Google Home needed DHCP, so DHCP is needed. Also, I don't feel that DNS is particularly necessary.
The required functions were judged to be the following two points.
When I put Buster in and searched again, I found someone who was already doing what they were trying to do. Thanks. I decided to use isc-dhcp-server instead of dnsmasq, referring to the following site.
Build hawksnowlog: RaspberryPi as an extended access point for mobile routers
I also referred to the following site. Thanks. Turn Raspberry Pi into a WiFi access point!
First, make sure your Wi-Fi dongle is enabled. I was able to confirm that I was recognizing it just by pointing it.
pi@raspberrypi:~ $ ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
...
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
...
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500、
...
wlan1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
...
Only wlan1 is set to automatically connect to mobile Wi-Fi. If I didn't set anything, both were connected to mobile Wi-Fi that I had already connected to. I set it referring to here. What I was addicted to when inserting two Wi-Fi adapters on Raspberry Pi-Qiita
From this section, it was executed with reference to the following site. I wanted to switch wlan0 and wlan1 and set them, so I paid attention to that and executed the same. Build hawksnowlog: RaspberryPi as an extended access point for mobile routers
I did it as instructed. No error was displayed.
I did it as instructed. No error was displayed.
Installation and settings are completed without any errors.
An error occurred when starting up the DHCP server. It is shown below.
$ sudo systemctl start isc-dhcp-server
Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details
The command was executed according to the message.
When I ran systemctl status isc-dhcp-server.service
, I didn't notice anything in particular.
Next, when I executed the following command, an error was displayed.
$ journalctl -xn
...
no subnet declaration for wlan0 (no ipv4 addresses)
...
I reviewed the settings, but it didn't improve.
I checked some sites here, but couldn't get any useful information.
ʻIfconfig, I remembered that the IP was not assigned, and assumed that this was a problem, and confirmed some. I was not confident about how to set the fixed IP and how to write the settings of the two wlans separately, so I reviewed the settings while checking some sites, but I could not solve it. I decided to change the IP specification method and check it, so I wrote the fixed IP setting in
/ etc / network / interface instead of
/etc/dhcpcd.conf and restarted. When I reconfirmed with ʻifconfig
, the IP was assigned.
In that state, again
sudo systemctl start isc-dhcp-server
Then, I was able to execute it without any error. I was able to connect to the Internet by connecting to the specified SSID from another terminal. Even after restarting, I was able to confirm that I could connect from another terminal. It was not necessary to execute the above command when restarting.
It seems that it is not recommended to write a fixed IP setting to interface from Raspbian a few years ago, so it is not a very clean solution, but I was able to confirm the operation, so I will operate it for the time being. Also, since the link is attached to interfaces.d, it may be better to write it in that directory, but I did not find the merit of taking time, so I forgot to respond. The fixed IP + α configuration file is shown below for reference.
interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.130.1/24
netmask 255.255.255.0
gateway 192.168.130.1
# iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan0.conf
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant_wlan1.conf
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
When I connected to the Internet via Raspberry Pi and did a speed test, it was about 1/5. It seems that it will change depending on the time of day and the situation of other connected terminals, but it is judged that there is no particular problem because the speed is sufficient now. If there is a problem, we will deal with it again.
I checked the 2.4GHz band channel and decided to change it to a place that seems to be there. If possible, I would like to use the 5GHz band, which has a lot of space, but I remember that Google Nest only supported 2.4GHz, so I did that. There may be a way to use both, but it's on hold. Consider when the performance is insufficient.
First, we selected the software used to check the channel. I decided to put an Android app on my Chromebook. After checking some reviews and appearance, I chose WiFi Analyzer (open-source). The reason for selection is because it says ʻopen-source`. Judging that there is a high possibility that there is no advertisement.
When I checked the channel, it looked like this. You can see that the mobile Wi-Fi channel and the Raspberry Pi channel overlap.
I decided to change to channel 1 where the signal power of other Wi-Fi is relatively weak.
Rewrite hostapd.conf according to the procedure described in Referenced site and execute the following command. I ran it.
sudo systemctl restart hostapd
sudo /etc/init.d/isc-dhcp-server restart
I checked again. You can see that the channel has moved.
Here's what I want to do in the future.
--Review the channel (Completed: 2020/02/29) --Review the fixed IP settings. --Consider whether to connect your home device to mobile Wi-Fi or Raspberry Wi-Fi.
Although there are some parts that seem to be forced to operate, it was confirmed that they work safely. It's not limited to this setting, but it's difficult to debug. You can find out which function works in which configuration file by searching, but you cannot determine the optimum debug flow when an error occurs. This error message was not direct, so it took extra time. One solution seems to have been able to debug a little faster by understanding the behavior of DHCP and APs. In the future, I would like to try to shorten the debugging time and improve the application power by spending more time understanding the functions to be used. However, it may not be the ultimate solution because we think the same thing every time. I would like to discuss how to debug when using a technology that I do not know.
With the current settings (fcitx-mozc), Ctrl-Space switches between English and Japanese input. Raspberry Pi uses a Japanese keyboard. If you are using Emacs, it will be a problem, so disable it. It could be disabled by setting according to the following site.
How to disable input switching when using Ctrl-Space on Raspberry Pi 63rd Raspbian Stretch and Japanese conversion (fcitx-mozc) | Device Plus --Devapla
I also checked rc.local. The following site was helpful. rc.local - Raspberry Pi Documentation Setting of command (program) to be automatically executed when linux starts-Qiita
Recommended Posts