2021-11-01
Host a wireless access point on Linux from the command line
This script with it's two related configuration files worked on Raspberry Pi Raspbian Linux. What was always sketchy was the "driver=" line in the hostapd.conf. I was disappointed that it could only host 802.11g or 802.11n. I even messed around with USB-attached WiFi to host, but the Raspberry Pi 3's always were limited for power no matter how high-end of a power connection I provided. I had many more problems with Fedora but this was approximately Fedora 29 vintage or so. This script continues to fascinate me, but I no longer have the energy to beat my head against the wall until it works. I once ran a Fedora desktop for an emergency bridge (not with this script) but the WiFi was always a problem to the other building, due to the poor access point in the other building.
$ cat /local/etc/hostap
#!/bin/bash
killall -9 hostapd
#/usr/sbin/ifconfig wlan1 10.121.11.1 netmask 255.255.255.0 up
/usr/sbin/ifconfig wlan1 10.121.11.1 netmask 255.255.255.0 up
/usr/bin/killall -9 /usr/sbin/hostapd
/usr/sbin/hostapd -t -B /etc/hostapd/hostapd.conf
/usr/bin/killall -9 dhcpd
/usr/sbin/dhcpd wlan1
/usr/sbin/iptables -L -t nat | /bin/grep MASQUERADE ||
{
/sbin/sysctl -w net.ipv4.ip_forward=1
/sbin/sysctl -w net.ipv6.conf.all.forwarding=1
$ipt -t nat -F
$ipt -F
$ipt --table nat --append POSTROUTING -s 10.121.11.0/24 -j MASQUERADE
}
$ cat /etc/hostapd/hostapd.conf
interface=wlan0
#driver=rtl871xdrv
#driver=nl80211
hw_mode=g
#hw_mode=n
#driver=nl80211
ssid=TEST-WiFi-NAME
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=WIFI-PASSWORD-GOES-HERE
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_ptk_rekey=600
macaddr_acl=0
$ cat /etc/dhcpd.conf
shared-network iphonenet {
subnet 10.123.213.0 netmask 255.255.255.0 {
range 10.123.213.10 10.123.213.50;
option broadcast-address 10.123.213.255;
option routers 10.123.213.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name-servers 8.8.8.8, 4.2.2.2, 8.8.4.4;
}
}
</preformatted>
Subscribe to:
Post Comments (Atom)
Script to see network interface connection speed
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...
-
This script with it's two related configuration files worked on Raspberry Pi Raspbian Linux. What was always sketchy was the "dri...
-
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. Send...
-
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...
No comments:
Post a Comment