gnome-control-center icon indicating copy to clipboard operation
gnome-control-center copied to clipboard

NAT not being configured for wired, wireless (hotspot) network sharing

Open jacobgkau opened this issue 1 year ago • 0 comments

When attempting to share a WiFi connection via Ethernet by opening the Ethernet connection settings and setting IPv4 to Shared to other computers, a client connected via Ethernet was able to establish a connection, but the client could not access the internet. Wireguard on the sharing computer showed that packets were coming in on the Ethernet interface, but were not being forwarded out the WiFi interface.

After running these commands to set up NAT with iptables, sharing started working:

root@pop-os:~# iptables --flush
root@pop-os:~# iptables -t nat -A POSTROUTING -o wlp0s20f3 -j MASQUERADE
root@pop-os:~# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
root@pop-os:~# iptables -A FORWARD -i enp35s0 -o wlp0s20f3 -j ACCEPT

The client computer connected via Ethernet was then able to send and receive traffic to/from the public internet via the sharing computer.

Similarly, after rebooting (to clear the iptables setup), when I connected the sharing computer back to a normal Ethernet connection (with internet) and attempted to share the connection wirelessly via Wi-Fi -> Turn On Wi-Fi Hotspot..., an Android phone was able to establish a connection, but did not have internet access. After running the NAT commands with the interfaces reversed:

root@pop-os:~# iptables --flush
root@pop-os:~# iptables -t nat -A POSTROUTING -o enp35s0 -j MASQUERADE
root@pop-os:~# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
root@pop-os:~# iptables -A FORWARD -i wlp0s20f3 -o enp35s0 -j ACCEPT

...the Android phone got internet.

This issue may supersede https://github.com/pop-os/gnome-control-center/issues/225 (I am no longer getting the Can't connect to network errors or authentication re-prompts mentioned in that issue.)

jacobgkau avatar Mar 22 '23 22:03 jacobgkau