Run this in a terminal:
sudo apt-get install hostapd
Then, open a text editor program, for example gedit. Copy the following into it.
interface=wlan0
driver=nl80211
ssid=francis-ubuntu
channel=1
hw_mode=g
auth_algs=1
wpa=3
wpa_passphrase=aaabbbccc
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Don't forget to fill in the name of your network after ssid= as well as the password after wpa_passphrase=.
After all these, save the file as hostapd.conf in your home folder.
Now, in your terminal:
sudo hostapd hostapd.conf
Turn the Wi-Fi connection on in your devices and enjoy the fast network share!
you might also want to add dhcpd
to assign address to your Android device. Alternatively you can configure iptables to use NAT
- http://wiki.ubuntu.org.cn/%E5%AE%89%E8%A3%85DHCP
- http://nyc1991.blog.51cto.com/6424159/1120857
- http://www.cyberciti.biz/faq/howto-ubuntu-debian-squeeze-dhcp-server-setup-tutorial/ (recommend)
- http://wiki.centos.org/HowTos/Network/IPTables
- http://informationsecuritytips.com/2010/10/command-to-reset-iptables-firewall-in-ubuntu/
- http://askubuntu.com/questions/90314/unable-to-edit-proc-sys-net-ipv4-ip-forward-in-xubuntu
sudo apt-get install isc-dhcp-server //dhcp服务器,网上有许多是用网桥实现,但我觉得用这个dhcp服务器更简单
安装完以后,在/etc/dhcp/目录下建立文件dhcpd.conf,内容如下:
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
## dhcp start and end IP range ##
range 192.168.1.100 192.168.1.200;
option subnet-mask 255.255.255.0; ## subnet
option domain-name-servers 8.8.8.8,8.8.4.4;
option broadcast-address 192.168.1.255; ## broadcast
option routers 192.168.1.254; ## router IP
}
Save and close the file. To check the syntax of dhcpd.conf file for errors, run:
# dhcpd -t
OR # dhcpd -t /etc/dhcp/dhcpd.conf
How do I start / stop / restart the DHCP server?
Type the following commands:
service isc-dhcp-server start
service isc-dhcp-server stop
service isc-dhcp-server restart
service isc-dhcp-server status
How do I verify that DHCP server UDP port # 67 is opened by dhcpd?
Type any one of the following command
# netstat -tulpn | grep --color "dhcp"
OR
# ps aux | grep --color "[d]hcpd"
OR
# pgrep dhcpd
#/bin/bash!
# https://bugs.launchpad.net/ubuntu/+source/wpa/+bug/1289047
# Temporary solution for hostapd not work with 14.04
sudo nmcli nm wifi off
sudo rfkill unblock wlan
sudo killall hostapd
sudo ifconfig wlan0 192.168.1.254 netmask 255.255.255.0
sudo hostapd /etc/hostapd/hostapd.conf -B
sudo start isc-dhcp-server
sudo iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.1.0/24 -m state --state NEW -j ACCEPT
# sudo iptables -A INPUT -s 192.168.1.0/255.255.255.0 -j ACCEPT # using a subnet mask
sudo iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
sudo sh softAP.sh
http://unix.stackexchange.com/questions/58461/isc-dhcp-server-fails-to-start-at-boot
dmesg | grep isc-dhcp-server
[ 15.267804] init: isc-dhcp-server main process (1201) terminated with status 1
[ 15.267839] init: isc-dhcp-server main process ended, respawning
#list all rules
sudo iptable -L
sudo iptable -F
/proc
是系统动态生成的, 关机就没有了。
如果需要一直启用编辑 /etc/sysctl.conf
$ vi /etc/sysctl.conf
iwconfig
sudo /sbin/ifconfig wlan0 up
How can i create it?