如何创建非adhoc wifi热点?

我想通过有线以太网连接(eth0)使用我的桌面来操作我的“TP-LINK TL-WN722N”USB Wifi适配器(wlan0)作为我的Android连接的非adhoc(基础设施模式)接入点。

经过多次搜索,我终于找到了一种方法(遍布许多网站),完成了我需要的大部分工作……

依赖关系:

hostapd bridge-utils 

我修改了“/ etc / network / interfaces”

 sudo gedit /etc/network/interfaces 

包含装有:

 # This file describes the network interfaces available on your system # and how to activate them. auto lo br0 iface lo inet loopback allow-hotplug eth0 iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual # Bridge setup # for dhcp address iface br0 inet dhcp bridge_ports eth0 wlan0 # for static ip # iface br0 inet static # bridge_ports eth0 wlan0 # adapt with your network settings # address 192.168.1.250 # netmask 255.255.255.0 # network 192.168.1.0 # broadcast 192.168.1.255 # gateway 192.168.1.1 # dns-* options are implemented by the resolvconf package, if installed # dns-nameservers 192.168.1.1 # dns-search localdomain ### Reference ### # Creating a Wireless Access Point with Debian Linux « Agent Oss (October 31, 2011) # https://agentoss.wordpress.com/2011/10/31/creating-a-wireless-access-point-with-debian-linux/ 

我的“/etc/hostapd/hostapd.conf”(我以某种方式设法将自己组合在一起)

 sudo gedit /etc/hostapd/hostapd.conf 

包含:

  ### Guts ### interface=wlan0 bridge=br0 driver=nl80211 ### General ### ssid=____________________ hw_mode=g channel=1 ### Security ### macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 ## 0 visible # 1 hidden ## wpa=2 wpa_passphrase=____________________ wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP ### Reference ### ## Created Tuesday, February 14, 2012 ## Ubuntu 11.10/12.04 ## # Hostapd Linux Documentation Page # http://linuxwireless.org/en/users/Documentation/hostapd # Creating a Network Bridge on Ubuntu (January 16th, 2011) # http://webserver.linuxportal.nl/?p=422 

(我已经删除了这篇文章的安全位)

所有这些都允许我打开终端并执行:

  sudo hostapd -B /etc/hostapd/hostapd.conf 

有一个function正常的接入点,我的Android和所有其他WiFi设备可以连接到。

除了与其他人共享此方法,因为此设置的信息非常稀疏; 有三个问题很好修复:

  1. 此配置将停用网络管理器及其所有function。 单击它时,它会显示“设备未管理”消息。 (不是必需的,但对我来说有点烦)
  2. 此方法可能会不时地与IP地址斗争。
  3. 我必须使用终端打开Wifi。 (对我来说好,但不适合家庭)。 我想出如何使用gksu和一个简单的脚本制作一个启动器,如果有人需要一个…

在没有终端的情况下启动wifi / Hostapd

  1. (为什么网络管理员不能开箱即用?)

提前致谢! 我希望所有这些都可以帮助别人; 我以前从未写过教程,对网络几乎一无所知……

也许与网桥有关- 不破坏网络管理员 (等等)。

使用Ubuntu 11.10,12.04进行测试。

我不确定如何在不破坏NM的情况下执行此操作,但可以在启动时自动运行并轻松分配IP地址(至少我已使用相同的无线卡进行管理)。 这需要包hostapddnsmasq (不是dnsmasq-base

/etc/hostapd/hostapd.conf:

 interface=wlan0 driver=nl80211 # This works on my TL-WN722N ssid=______ channel=6 hw_mode=g auth_algs=1 wpa=3 wpa_passphrase=_____ wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP rsn_pairwise=CCMP 

在/ etc /默认/ hostapd:

 # Defaults for hostapd initscript # # See /usr/share/doc/hostapd/README.Debian for information about alternative # methods of managing hostapd. # # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration # file and hostapd will be started during system boot. An example configuration # file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz # DAEMON_CONF="/etc/hostapd/hostapd.conf" # Additional daemon options to be appended to hostapd command:- # -d show more debug messages (-dd for even more) # -K include key data in debug messages # -t include timestamps in some debug messages # # Note that -B (daemon mode) and -P (pidfile) options are automatically # configured by the init.d script and must not be added to DAEMON_OPTS. # #DAEMON_OPTS="" 

/etc/dnsmasq.conf(针对维护者版本的差异):

 --- /etc/dnsmasq.conf.dpkg-dist 2011-09-20 00:28:30.000000000 +0100 +++ /etc/dnsmasq.conf 2012-02-13 21:03:03.713554612 +0000 @@ -82,7 +82,7 @@ # specified interfaces (and the loopback) give the name of the # interface (eg eth0) here. # Repeat the line for more than one interface. -#interface= +interface=wlan0 # Or you can specify which interface _not_ to listen on #except-interface= # Or which to listen on by address (remember to include 127.0.0.1 if @@ -133,7 +133,7 @@ # a lease time. If you have more than one network, you will need to # repeat this for each network on which you want to supply DHCP # service. -#dhcp-range=192.168.0.50,192.168.0.150,12h +dhcp-range=192.168.3.10,192.168.3.49,12h # This is an example of a DHCP range where the netmask is given. This # is needed for networks we reach the dnsmasq DHCP server via a relay 

的/ etc /网络/接口:

 auto lo iface lo inet loopback auto wlan0 iface wlan0 inet static address 192.168.3.1/24 broadcast 192.168.3.255 

/etc/sysctl.conf补丁(更改后运行sudo sysctl -p /etc/sysctl.conf ):

 --- sysctl.conf 2012-05-14 18:06:57.514873009 +0100 +++ /etc/sysctl.conf 2012-05-14 18:09:27.122876525 +0100 @@ -25,7 +25,7 @@ #net.ipv4.tcp_syncookies=1 # Uncomment the next line to enable packet forwarding for IPv4 -#net.ipv4.ip_forward=1 +net.ipv4.ip_forward=1 # Uncomment the next line to enable packet forwarding for IPv6 # Enabling this option disables Stateless Address Autoconfiguration 

最后,在iptables设置NAT:

 sudo iptables -A FORWARD -o eth0 -i eth1 -s 192.168.0.0/24 -m conntrack --ctstate NEW -j ACCEPT sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT sudo iptables -A POSTROUTING -t nat -j MASQUERADE sudo iptables-save | sudo tee /etc/iptables.sav 

并在/etc/rc.local exit 0上方添加iptables-restore < /etc/iptables.sav

这个设置主要是通过阅读这个howto并盯着看到我的脑袋的手册来实现的。

由于惠普笔记本电脑中的Broadcom驱动程序至少会出现大多数问题。 如果您有broadcom网络控制器检查您的卡是否与b43兼容(链接1)。 如果它,真棒,继续阅读。 默认的Broadcom sta驱动程序(wl)不支持访问点模式。 因此,安装b43采取预防措施,以任何必要的方式在线。 使用modprobe打开它。 现在按照说明操作并尝试设置接入点。

我终于得到了hostapd使用这个和甜蜜的部分是我的诺基亚手机可以检测到如此创建的无线网络(它可以检测任何事情,特别是或不)。 现在我必须玩你的文件,看看我是否可以让我的剧本检测。

  1. http://linuxwireless.org/en/users/Drivers/b43
  2. http://pclinuxos.com/forum/index.php?topic=91991.0

上面的优秀答案,但不只是一个或两个不支持hostapd或AP模式的芯片组。

以下是如何查看您的驱动程序和硬件是否支持AP模式:

 sudo iw list | less 

查找“支持的接口模式”部分。 如果它不包括“AP”,那你就不走运了。 如果它确实说“AP”,那么继续其他海报已经提供的许多好的指示!