Be aware that some mobile operators use Carrier Grade NAT. That makes it impossible to directly call in. (To the RPi or any other data equipment.)
Thanks, I was unaware of this problem.
I'd do that. Don't forget to remove the 'bridge=br0' line from hostapd.conf -- you won't be using it, after all -- and you'd best check what he means byBosse_B wrote: ↑Sat Oct 12, 2019 11:56 amWhat is the easiest way to accomplish this?
Is it as simple as using this guide but only using steps 1-5 and stopping at step #6?
Code: Select all
denyinterfaces eth0
denyinterfaces wlan0
Code: Select all
sudo apt install dnsmasq hostapd
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
sudo nano /etc/dhcpcd.conf
Add to end of file:
interface wlan0
static ip_address=192.168.197.1/24
nohook wpa_supplicant
Code: Select all
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
Add to new file:
interface=wlan0 # Use the require wireless interface - usually wlan0
dhcp-range=192.168.197.10,192.168.197.30,255.255.255.0,24h
Code: Select all
sudo nano /etc/hostapd/hostapd.conf
Add to new file
interface=wlan0
driver=nl80211
ssid=NameOfNetwork
wpa_passphrase=PasswordOfNetwork
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Code: Select all
sudo nano /etc/default/hostapd
Modify daemon line:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Code: Select all
sudo service dhcpcd restart
Code: Select all
sudo systemctl unmask host
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
Code: Select all
sudo systemctl status hostapd
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: enabled)
Active: activating (start) since Sun 2019-10-13 00:35:12 CEST; 234ms ago
Cntrl PID: 29928 (hostapd)
Tasks: 1 (limit: 4915)
Memory: 488.0K
CGroup: /system.slice/hostapd.service
└─29928 /usr/sbin/hostapd -B -P /run/hostapd.pid -B /etc/hostapd/hostapd.conf /etc/hostapd/hostapd.conf
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: AP-ENABLED
Oct 13 00:35:12 rpi4-test hostapd[29928]: Could not set channel for kernel driver
Oct 13 00:35:12 rpi4-test hostapd[29928]: Interface initialization failed
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: interface state UNINITIALIZED->DISABLED
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: AP-DISABLED
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: Unable to setup interface.
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: interface state ENABLED->DISABLED
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: AP-DISABLED
Oct 13 00:35:12 rpi4-test hostapd[29928]: wlan0: CTRL-EVENT-TERMINATING
Oct 13 00:35:12 rpi4-test hostapd[29928]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Code: Select all
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.9 netmask 255.255.255.0 broadcast 10.0.3.255
inet6 fe80::fffa:e103:a4c9:1230 prefixlen 64 scopeid 0x20<link>
ether dc:a6:32:05:6c:d9 txqueuelen 1000 (Ethernet)
RX packets 579054 bytes 139657892 (133.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32546 bytes 9315898 (8.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 30 bytes 4254 (4.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 30 bytes 4254 (4.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether dc:a6:32:05:6c:db txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 58756 bytes 6241938 (5.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Code: Select all
sudo ip link set wlan0 down
Code: Select all
sudo systemctl status hostapd
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator
Loaded: loaded (/lib/systemd/system/hostapd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Sun 2019-10-13 17:27:47 CEST; 1s ago
Process: 1502 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=1/FAILURE)
sudo systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-10-13 15:18:15 CEST; 2h 10min ago
Process: 419 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
Process: 443 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
Process: 547 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
Main PID: 546 (dnsmasq)
Tasks: 1 (limit: 4915)
Memory: 2.5M
CGroup: /system.slice/dnsmasq.service
└─546 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist
Oct 13 15:18:15 rpi4-test dnsmasq[546]: warning: interface wlan0 does not currently exist
Oct 13 15:18:15 rpi4-test dnsmasq-dhcp[546]: DHCP, IP range 192.168.197.11 -- 192.168.197.30, lease time 1d
Oct 13 15:18:15 rpi4-test dnsmasq[546]: read /etc/hosts - 5 addresses
Oct 13 15:18:15 rpi4-test dnsmasq[546]: no servers found in /run/dnsmasq/resolv.conf, will retry
Oct 13 15:18:15 rpi4-test dnsmasq[547]: Too few arguments.
Oct 13 15:18:15 rpi4-test dnsmasq[547]: Too few arguments.
Oct 13 15:18:15 rpi4-test systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Oct 13 15:18:35 rpi4-test dnsmasq[546]: reading /run/dnsmasq/resolv.conf
Oct 13 15:18:36 rpi4-test dnsmasq[546]: using nameserver 208.91.112.53#53
Oct 13 15:18:36 rpi4-test dnsmasq[546]: using nameserver 208.91.112.52#53
Thanks, I will have a look.Anyway long story short, I can give you the link so you that you can set up your rpi as an access point and allowing routing on both wifi and ethernet interfaces. It uses systemd which apparently it's the new big thing, also, posts by this guy are pretty awesome on networking so hope this helps
Then the setup for my specific use (other cases in the quoted webpage):General Setup
Switch over to systemd-networkd
For detailed information look at [urlhttps://raspberrypi.stackexchange.com/a/78788/79866](1)[/url]. Here only in short. Execute these commands:Configure wpa_supplicant as access pointCode: Select all
# disable classic networking rpi ~$ sudo -Es rpi ~# systemctl mask networking.service dhcpcd.service rpi ~# mv /etc/network/interfaces /etc/network/interfaces~ rpi ~# sed -i '1i resolvconf=NO' /etc/resolvconf.conf # enable systemd-networkd rpi ~# systemctl enable systemd-networkd.service systemd-resolved.service rpi ~# ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
To configure wpa_supplicant as access point create this file with your settings for country=, ssid=, psk= and maybe frequency=. You can just copy and paste this in one block to your command line beginning with cat and including both EOF (delimiter EOF will not get part of the file):
Finished General setup. Go back.Code: Select all
rpi ~# cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF country=DE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="RPiNet" mode=2 frequency=2437 #key_mgmt=NONE # uncomment this for an open hotspot # delete next 3 lines if key_mgmt=NONE key_mgmt=WPA-PSK proto=RSN WPA psk="password" } EOF rpi ~# chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf rpi ~# systemctl disable wpa_supplicant.service rpi ~# systemctl enable wpa_supplicant@wlan0.service
What I do not find here is how to set up the range of IP addresses connected devices will get...Setting up a stand alone access point
Example for this setup:
Do "General setup" then create the following file to configure wlan0.Code: Select all
wifi mobile-phone <~.~.~.~.~> (wlan0)RPi(eth0) \ / (dhcp) 192.168.4.1
We only have the access point. There is no ethernet device configured.
If you want this then reboot.Code: Select all
rpi ~# cat > /etc/systemd/network/08-wlan0.network <<EOF [Match] Name=wlan0 [Network] Address=192.168.4.1/24 DHCPServer=yes EOF
That's it.
Maybe it is time to regroup.
Well, as described above I actually have used this tutorial and it got me to an unstable situation.
Code: Select all
sudo reboot
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
sudo apt remove dnsmasq hostapd
sudo apt autoremove
sudo reboot
cd /etc/wpa_supplicant/
sudo mv wpa_supplicant-wlan0.conf wpa_supplicant-wlan0.conf.bak
sudo cp wpa_supplicant-wlan0.conf.bak wpa_supplicant-wlan0.conf
sudo nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
Code: Select all
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
Code: Select all
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=SE
network={
ssid="*******"
psk="********"
}
Code: Select all
rpi ~# cat > /etc/dnsmasq.conf <<EOF
interface=br0
dhcp-range=192.168.50.128,192.168.50.164,255.255.255.0,24h
dhcp-option=option:router,192.168.50.1
dhcp-option=option:dns-server,8.8.8.8,1.1.1.1
EOF