Creating ad-hoc Wi-Fi network used for sharing wired Internet
connection using shell commands should be simple. Although I don't use
Fedora setting up wireless networks should work similarly on all
desktop Linux systems.
First, let's make sure that all components required to setup wireless
network are available and install them if they are not:
$ command -v hostapd dnsmasq iptables ip
We'll put all configs in a dedicated
directory so that we can find them easily:
mkdir ~/wireless-network-setup && cd ~/wireless-network-setup
As stated on https://w1.fi/hostapd/:
hostapd is a user space daemon for access point and authentication
servers. It implements IEEE 802.11 access point management, IEEE
802.1X/WPA/WPA2/EAP Authenticators, RADIUS client, EAP server, and RADIUS authentication server. The current version supports Linux (Host
AP, madwifi, mac80211-based drivers) and FreeBSD (net80211).
Put this in
This will create Wi-Fi network with
FREE-Wi-Fi SSID, WPA2 security
dnsmasq is DHCP server. It will assign IP addresses to Wi-Fi network
clients. Put this in
DHCP server cannot provide IP address to itself so we have to set
wlan0 interface IP address manually:
sudo ip addr add 10.0.0.1/16 dev wlan0
sudo ip link set wlan0 up
iptables is a firewall tool. We have to tell it to redirect traffic
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -P FORWARD ACCEPT
If your Internet-facing interface is not named
eth0 modify its name
That's the whole configuration. Start
sudo hostapd -B hostapd.conf
sudo dnsmasq -C dnsmasq.conf
Now you should be able to connect to
Free-Wi-Fi network from other
devices and access the internet.
Notice that in Fedora both dnsmasq and hostapd probably come with
customized init startup scripts that you can use instead of starting
them manually like that.
Also notice that if you're using some specific hardware, for example
rtl8188eu you will have to use forked