When I had made something once more with the Raspberry Pi and I wanted to bind a sensor about WLAN, I have bumped into a problem. If I liked to connect in the Raspberry Pi a sensor with WLAN, I need a WLAN, in addition, as a hardware. The Raspberry Pi owns a WLAN module, why not this use as an AccessPoint and save the router?
How this is furnished, we show you today here:
In this blog we use a Raspberry Pi 3 B and a SD map with topical image (Raspbian Stretch Lite - release date: In 2018-10-09)
Around directly without screen can configure the Raspberry Pi about SSH a file with the name "ssh" on the boat partition put away. This is explained in the Raspberry Pi eBook in detail, here only as a short tip.
As the next we log in on the Raspberry Pi and make a vollständies update:
sudo apt-get updates && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove && sudo apt-get autoclean
After our Raspberry Pi is topical now, we configure the network interface WLAN with a firm IP.
Now in the file we write the following:
# interfaces (5) files used by ifup (8) and ifdown (8)
# Please miseries that this file is written to Be used with dhcpcd
# For static IP, consult/etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from/etc/network/interfaces.d:
iface lo inet loop forecastle
iface eth0 inet dhcp
iface wlan0 inet static
This configuration causes that the Raspberry Pi gets now the IP address 192.168.222.1 on the WLAN interface firm and gets with the LAN interface still an IP address dynamically assigned.
Because we would like to use the Raspberry Pi now as "a server", we must deactivate the DHCP client on the WLAN interface.
Completely at the end of the file we complement the following line:
Afterwards rebooten we the Raspberry Pi with:
After the restart we instal a DHCP and DNA server and configure this:
sudo apt-get instal dnsmasq
If one wanted one can protect the old configuration:
Now the following configuration comes to the file:
no dhcp interface=eth0
With this configuration makes available of the Raspberry now a DNA server on 192.168.222.1 and the DHCP server awards the IP addresses of 192,168,222.10 - 200. On the network interface LAN the DHCP server is not active.
If you have changed the values and/or want to test whether the configuration was properly taken over, you can test this with this order:
dnsmasq - test-C/etc/dnsmasq.conf
as an answer had to go "dnsmasq: syntax check OK." appear.
Now we put on one more autostart, so that in future everything automatically starts with a restart:
sudo systemctl enable dnsmasq
Afterwards rebooten we the Raspberry Pi again with:
As the last step we activate and instal an AccessPoint:
sudo apt-get instal hostapd
interface=wlan0 ssid=raspberry-wlan channel=1 hw_mode=g ieee80211n=1 ieee80211d=1 country_code=DE wmm_enabled=1 auth_algs=1 wpa=2 wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP wpa_passphrase=az-delivery
Now with this Konfiguraton we generate a signal WLAN on canal 1, with the name "raspberry-wlan" and the password "az-delivery".
If the WLAN should now be created automatically after a reboot, we have to activate it again in the autostart:
sudo nano / etc / default / hostapd
We add the following file content at the end of the file:
RUN_DAEMON = yes DAEMON_CONF = "/ etc / hostapd / hostapd.conf"
And then activate it in the system:
sudo systemctl start hostapd
sudo systemctl enable hostapd
Now we can restart the Raspberry and call up the status at any time with this command:
sudo systemctl status hostapd
Now we see a new WLAN network in our WLAN overview and can connect to this network:
After entering the password:
Are we already connected?
The DHCP server on the Raspberry also runs because it assigns a correct IP address from the specified range:
Now we can use the Raspberry as a router to create further projects.
We wish you a lot of fun and let us know what you use the "Raspberry Router" for.