Skip to content

Commit f6e1643

Browse files
committed
Added NAT AP notes
1 parent be567ef commit f6e1643

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

WiFiAP.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,62 @@ and tested on the new Bookworm-based Raspberry Pi OS Lite.
3939
(it apparently doesn't support changing the `autoconnect` settings).
4040

4141

42+
Making the RPi a NAT Access Point for its Ethernet
43+
--------------------------------------------------
44+
45+
Assuming you're *not* using UFW! Otherwise, please see [my USB LTE Modem notes](./USB-LTE-Modem.md).
46+
47+
1. Checks
48+
- Ensure `net.ipv4.ip_forward=1` is on: `cat /proc/sys/net/ipv4/ip_forward`.
49+
If not, add a file in `/etc/sysctl.d` with that line.
50+
- `sudo nmcli c show Hotspot | grep ip4v.method` should show `shared`.
51+
2. Configure NAT with nftables
52+
- `sudo nft add table ip nat`
53+
- `sudo nft 'add chain ip nat postrouting { type nat hook postrouting priority 100 ; }'`
54+
- `sudo nft add rule ip nat postrouting oifname eth0 masquerade`
55+
3. Configure Forwarding Rules
56+
- `sudo nft add table ip filter`
57+
- `sudo nft 'add chain ip filter forward { type filter hook forward priority 0; policy accept; }'`
58+
- `sudo nft add rule ip filter forward ct state established,related accept`
59+
- `sudo nft add rule ip filter forward iifname wlan0 oifname eth0 accept`
60+
4. Persist Changes
61+
- `sudo nft list ruleset | sudo tee -a /etc/nftables.conf`
62+
- `cat /etc/nftables.conf` and read it to make sure it makes sense
63+
- `sudo systemctl enable nftables`
64+
65+
4266
Previous Manual Instructions
4367
----------------------------
4468

4569
**Unmaintained:** Assuming the above `nmcli` method continues to work well for me, I will eventually delete this section.
4670

4771
- Initial steps
48-
72+
4973
sudo apt-get install hostapd dnsmasq
5074
sudo systemctl stop dnsmasq
5175
sudo systemctl stop hostapd
5276
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
5377
sudo ufw allow DNS
5478
sudo ufw allow from any port 68 to any port 67 proto udp comment DHCP
55-
79+
5680
- `sudo vi /etc/dhcpcd.conf` and add the lines:
57-
81+
5882
interface wlan0
5983
static ip_address=192.168.42.1/24
6084
static domain_name_servers=192.168.42.1
6185
nohook wpa_supplicant
62-
86+
6387
- `sudo vi /etc/dnsmasq.conf` and add the lines:
64-
88+
6589
interface=wlan0
6690
domain-needed
6791
bogus-priv
6892
dhcp-range=192.168.42.100,192.168.42.150
6993
domain=internal
7094
address=/YOURHOSTNAME.internal/192.168.42.1
71-
95+
7296
- `sudo vi /etc/hostapd/hostapd.conf` and create or replace contents with:
73-
97+
7498
interface=wlan0
7599
driver=nl80211
76100
ssid=YOUR_SSID_HERE
@@ -86,15 +110,15 @@ Previous Manual Instructions
86110
wpa_key_mgmt=WPA-PSK
87111
wpa_pairwise=TKIP
88112
rsn_pairwise=CCMP
89-
113+
90114
- `sudo vi /etc/default/hostapd` and set
91115
`DAEMON_CONF="/etc/hostapd/hostapd.conf"`
92-
116+
93117
- Start things up:
94-
118+
95119
sudo systemctl unmask hostapd
96120
sudo reboot
97-
121+
98122
- To disable temporarily:
99123
- `sudo systemctl disable hostapd`
100124
- `sudo vi /etc/dhcpcd.conf` and comment out the lines added above

0 commit comments

Comments
 (0)