Share wired internet connection wireless
Saturday, July 30th, 2011This was done with Atheros AR5001 (ath5k, Linux Mint 10, 2.6.35).
Install hostapd and DHCP-server.
1 | apt-get install hostapd dhcp3-server |
/etc/hostapd/hostapd.conf:
1 2 3 4 5 6 7 8 9 10 | interface=wlan0 driver=nl80211 ssid=SSID hw_mode=g channel=7 wpa=2 wpa_passphrase=password wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP wpa_ptk_rekey=600 |
/etc/dhcp3/dhcpd.conf:
1 2 3 4 5 | subnet 10.10.0.0 netmask 255.255.255.0 { range 10.10.0.25 10.10.0.100; option domain-name-servers 193.213.112.4, 130.67.15.198; option routers 10.10.0.1; } |
Add to /etc/default/hostapd:
1 2 | RUN_DAEMON="yes" DAEMON_CONF="/etc/hostapd/hostapd.conf" |
/etc/default/dhcp3-server:
1 | INTERFACES="wlan0" |
/usr/local/bin/ics:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/bin/bash case "${1}" in start) # stop gnome network manager service network-manager stop # configure wireless IP ifconfig wlan0 10.10.0.1 netmask 255.255.255.0 up # start AP and DHCP-server service hostapd start service dhcp3-server start # enable NAT echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ;; stop) # disable NAT echo "0" > /proc/sys/net/ipv4/ip_forward iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # stop DHCP-server and AP service dhcp3-server stop service hostapd stop # start gnome network manager service network-manager start # wait 1 second and enable scanning on wireless sleep 1 ifconfig wlan0 up ;; esac exit 0 |
Add with to sudoers(with visudo):
1 2 | # Allow admin users to share internet connection %admin ALL=NOPASSWD:/usr/local/bin/ics |
Add shortcut to desktop with command "sudo /usr/local/bin/ics start" and "sudo /usr/local/bin/ics stop".