1

I would like to create a WiFi Hotspot using the Raspberry Pi. It does not have to provide a internet connection to the devices which are connected. But the raspberry Pi should still be connected to the WiFi so that it can be in the internet. I followed a tutorial to create a hotspot which works well. Unfortunately I cannot connect to the internet anymore with the raspberry pi. So is it possible that I create a "local" hotspot without internet and connect at the same time with my raspberry pi to a wifi network or is it simply impossible?

sudo nano /etc/dhcpcd.conf
interface wlan0
static ip_address=192.168.1.1/24

sudo systemctl restart dhcpcd


sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf_alt
sudo nano /etc/dnsmasq.conf

interface=wlan0

# DHCP-Server nicht aktiv für bestehendes Netzwerk
no-dhcp-interface=eth0

# IPv4-Adressbereich und Lease-Time
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,24h

# DNS
dhcp-option=option:dns-server,192.168.1.1


dnsmasq --test -C /etc/dnsmasq.conf
sudo systemctl restart dnsmasq
sudo systemctl status dnsmasq
sudo systemctl enable dnsmasq

sudo nano /etc/hostapd/hostapd.conf
# WLAN-Router-Betrieb

# Schnittstelle und Treiber
interface=wlan0
#driver=nl80211

# WLAN-Konfiguration
ssid=WLANrouter
channel=1
hw_mode=g
ieee80211n=1
ieee80211d=1
country_code=DE
wmm_enabled=1

# WLAN-Verschlüsselung
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=test


sudo chmod 600 /etc/hostapd/hostapd.conf

sudo hostapd -dd /etc/hostapd/hostapd.conf

sudo nano /etc/default/hostapd

# Adding 
RUN_DAEMON=yes
DAEMON_CONF="/etc/hostapd/hostapd.conf"

sudo systemctl unmask hostapd
sudo systemctl start hostapd
sudo systemctl enable hostapd

sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

sudo nano /etc/rc.local
#Adding
iptables-restore < /etc/iptables.ipv4.nat

sudo reboot

2

Yes, it is possible to establish an access point and connect the RasPi as client to your internet router at the same time only with one WiFi interface. It is able to use the physical interface wlan0 and create a second virtual interface ap0 on the same device. There is no need to use an additional WiFi dongle. How to do it you can look at Access point as WiFi router/repeater, optional with bridge.

Of course this example is made to connect the devices on the access point to the internet, because most people want this. But it is no problem to just cut the routing between access point and internet connection. In the tutorial in section Step 4: setup static interfaces you find to create the network file /etc/systemd/network/12-ap0.network. In this file just omit or comment the line IPMasquerade=yes. This is what the access point connects to the internet. Without it you are still able to connect from the RasPi direct to the internet using interface wlan0 but other devices on the access point cannot.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.