Ethernet to Wireless Hotspot
Hey everyone! Here’s a quick tutorial on how to share an Ethernet internet connection over a wireless hotspot. This allows other devices to access the internet via the wireless hotspot created on Mecha Comet.
Preview
Prerequisites
-
Ensure
nmcli
andnftables
are installed on Mecha Comet. -
You need sudo privileges to execute the commands.
-
Replace
wlan0
andend0
with your actual Wireless interface and outbound network interface names. -
Ensure mecha comet is connected to the Ethernet network.
Steps to Set Up the Hotspot
1. Create a Wireless Hotspot
Run the following command:
sudo nmcli device wifi hotspot ifname <wireless-interface> con-name <connection-name> ssid <ssid-name> password "<password>"
Replace the placeholders:
-
<wireless-interface>
: Your Wireless interface name (e.g.,wlan0
). -
<connection-name>
: Desired connection name (e.g.,comet-hotspot
). -
<ssid-name>
: Desired hotspot name (e.g.,CometHotspot
). -
<password>
: Desired password for the hotspot.
Example:
sudo nmcli device wifi hotspot ifname wlan0 con-name comet-hotspot ssid CometHotspot password "mechacomet"
-
ifname wlan0: Specifies the Wireless interface.
-
con-name comet-hotspot: Sets the connection name to
comet-hotspot
. -
ssid CometHotspot: Sets the SSID of the hotspot to
CometHotspot
. -
password “mechacomet”: Sets the password to
mechacomet
.
2. Configure IPv4 Method to Shared
Modify the hotspot connection to use a shared IPv4 method:
sudo nmcli connection modify <connection-name> ipv4.method shared
Example:
sudo nmcli connection modify "comet-hotspot" ipv4.method shared
3. Bring Up the Hotspot Connection
Activate the hotspot:
sudo nmcli connection up <connection-name>
Example:
sudo nmcli connection up "comet-hotspot"
4. Configure NAT with nftables
4.1 Create a NAT Table
sudo nft add table ip nat
4.2 Add a NAT Chain
sudo nft add chain ip nat POSTROUTING { type nat hook postrouting priority 100 \; }
4.3 Add a Masquerade Rule
Add a masquerade rule for outgoing traffic through the outbound interface:
sudo nft add rule ip nat POSTROUTING oif "end0" masquerade
- Replace
end0
with your outbound network interface name.
Verification
Check the Hotspot Status
nmcli device status
Verify nftables Rules
sudo nft list table ip nat
Notes
-
Replace interface names (
wlan0
,end0
) as needed for your setup. -
This setup assumes the Mecha Comet’s outbound interface is
end0
. Adjust accordingly.
Troubleshooting
-
If the hotspot fails to start, ensure the Wireless adapter is not connected to another network.
-
Verify that
nftables
is enabled and properly configured.
By following these steps, you should now have a functioning Wireless hotspot with NAT configured.