在Windows中,我可以使用Connectify Hotspot,它使我能够通过同一个无线适配器共享互联网连接,并在其上创建访问点。正如您可以在技术概述页面上阅读到的:
在Ubuntu上我该如何做到这一点?访问点模式允许您使用相同的Wi-Fi卡来创建热点,该卡也用于访问互联网。
在Ubuntu上我该如何做到这一点?访问点模式允许您使用相同的Wi-Fi卡来创建热点,该卡也用于访问互联网。
简单步骤:在Ubuntu中创建WiFi热点
打开终端(Ctrl+Alt+T),并输入以下命令,将其中的连接名称替换为第5步中使用的名称。
sudo gedit /etc/NetworkManager/system-connections/wifi-hotspot
找到mode=infrastructure
并将其改为mode=ap
现在检查网络部分,Wi-Fi将自动连接到创建的热点。如果找不到,请转到“连接到隐藏网络...”找到该连接并连接。
来源:http://ubuntuhandbook.org/index.php/2014/09/3-ways-create-wifi-hotspot-ubuntu/
nm-connection-editor
来打开“网络连接”界面。 - Leopd在我看到这个链接由vasishath提供后,我成功地设置了一个无线热点,以共享来自同一单一无线接口设备的互联网连接。这个无线设备必须使用已经构建有Atheros驱动程序并支持nl80211的驱动程序。接下来我将向您展示如何操作。
在终端中运行以下命令:
lsmod | grep ath
cfg80211
,继续操作没有意义,你应该注意this answer中的第二和第三点。
检查以下提到的软件包是否已安装:iw,hostapd,iptables,udhcpd,udhcpc,macchanger。
你可以使用以下命令安装它们:
sudo apt-get install iw hostapd iptables udhcpd udhcpc macchanger
在终端中运行以下命令以编辑相应的文件:
sudo -H gedit /etc/hostapd.conf /etc/udhcpd.conf /etc/default/udhcpd /etc/wpa_supplicant.conf
hostapd.conf
文件中添加以下代码:
interface=new1
driver=nl80211
ssid=my_wifi_hotspot #根据您的喜好更改ssid名称
channel=11 #建议使用与您的无线网络相同的信道
hw_mode=g
wme_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=1234567890 #根据您的喜好更改密码短语
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
udhcpd.conf
文件中注释掉所有当前行(在行前面添加#
字符),并添加以下新行:
start 192.168.0.102 #这些IP地址必须与您当前默认路由的子网相同
end 192.168.0.117
interface new1
opt dns 192.168.0.1 #您当前默认路由(网关)
option subnet 255.255.255.0
opt router 192.168.0.101 #此IP地址必须与您当前默认路由的子网相同
option domain localhost
wpa_supplicant.conf
中,您必须提供当前无线网络的设置。请参阅man wpa_supplicant
以获取一些快速示例。您可能还可以在/usr/share/doc/wpa_supplicant/
目录中找到更多示例。我使用了类似以下的设置:ctrl_interface=/var/run/wpa_supplicant
network={
ssid="my_wifi_network"
key_mgmt=WPA-PSK
proto=WPA
pairwise=CCMP
group=CCMP
psk="mypassphrase"
}
#!/bin/bash
service network-manager stop
sleep 1
pkill -15 nm-applet
sleep 1
ifconfig wlan0 down #wlan0 - the name of your wireless adapter
sleep 1
iw phy phy0 interface add new0 type station
iw phy phy0 interface add new1 type __ap
sleep 2
ifconfig new0 down
macchanger --mac 00:11:22:33:44:55 new0
ifconfig new1 down
macchanger --mac 00:11:22:33:44:66 new1
ifconfig new0 up
ifconfig new1 up
ifconfig new1 192.168.0.101 up #192.168.0.101 - the same IP defined for router in 'udhcpd.conf' file
hostapd /etc/hostapd.conf &
sleep 2
service udhcpd start
wpa_supplicant -inew0 -c/etc/wpa_supplicant.conf &
sleep 10
udhcpc -i new0
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables --table nat --append POSTROUTING --out-interface new0 -j MASQUERADE
iptables --append FORWARD --in-interface new1 -j ACCEPT
chmod +x ~/bin/hotspotsetup.sh
- 为脚本授予执行权限。以 root 权限在终端中运行上述脚本:
sudo ~/bin/hotspotsetup.sh
/etc/default/udhcp.conf
中启用udhcpd,但仍然没有运气。它一直给我发送 Sending discover...
和 new0: CTRL-EVENT-SCAN-STARTED
,尽管其他一切都进行得很顺利...当我尝试连接网络时也从未成功过!我已经根据您关于udhcpd的答案进行了编辑,但您能否告诉我如何解决连接问题? - Richardsudo apt install bash util-linux procps hostapd iproute2 iw wireless-tools haveged iptables dnsmasq git
git clone https://github.com/oblique/create_ap.git
在下载的存储库中找到您的终端:
cd create_ap
sudo make install
(不需要进行编译)
很简单,对吧?
剩下的更容易... ...如果您的设备能够同时用作客户端和PA(例如atheros wifi芯片-编辑:某些Intel芯片也是如此,请参见下面的第二条评论),您只需像通常一样使用网络管理器连接到家庭路由器,然后执行类似以下命令行:
sudo create_ap <connected interface> <repeater interface> <essid repeated network> <WPA Key>
sudo create_ap wlp2s0 wlp2s0 Bathroom_WiFi mysecuresecretkey
编辑 Oblique停止了这个项目
这个项目已不再维护。
免费代码的美妙之处在于好的项目永远不会消亡,有两个Github存储库继续保持Oblique的优秀工作:
systemctl start create_ap
,日志文件中没有任何内容,会出现create_ap
的错误提示。 - Ciasto piekarz正如您在对此答案的评论中所看到的,确实有一种方法可以做到这一点。在FreeBSD(不是Ubuntu/Linux)上有相关文档,链接在这里:https://serverfault.com/questions/192144/connect-to-multiple-ap-with-one-wifi-adapter-under-linux-freebsd(评论中的链接)。在Linux上似乎不能完全以相同的方式工作,但应该是类似的。不幸的是,我没有找到更详细的关于这个主题的信息。
可能最简单和最常见的方法是使用两个物理网络接口。因此,您可以购买另一个无线网卡或者使用其他技术来进一步连接,并且只使用其中一个通过Wifi连接。以下是一些可能性:
iwconfig
lsusb
lspci
lsmod
sudo apt-get install hostapd
sudo gedit /etc/hostapd/hostapd.conf
然后像这样进行编辑:
interface=wlan0
driver=nl80211
country_code=US
ssid=mySSID
hw_mode=g
channel=1
wpa=2
wpa_passphrase=MyWiFiPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
sudo gedit /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
RUN_DAEMON="yes"
DAEMON_OPTS="-dd"
DAEMON_CONF="/etc/hostapd/hostapd.conf /etc/hostapd/hostapd2.conf"
sudo update-rc.d hostapd defaults
sudo /etc/init.d/hostapd start
lspci | Wireless
像Purushoth's的答案一样,这个答案也需要2个WiFi适配器(例如:一个内部和一个外部USB WiFi适配器)。然而,我无法让他的答案对我起作用,所以这是我做的事情。
在Xubuntu 14.04中测试。
如何将Ubuntu/Xubuntu PC配置为WiFi热点(例如:在机场或飞机上使用,以便与您的手机和其他设备共享单个付费连接):
插入一个USB WiFi适配器。并非所有的适配器都可以作为“ap”(接入点)使用,但是内部的网卡肯定可以,所以我们将(至少暂时地,直到你找到一个可以作为接入点的USB wifi适配器)使用外部的USB适配器连接到付费服务(例如:机上WiFi),然后使用内部的wifi适配器创建wifi接入点。/etc/NetworkManager/system-connections
文件夹路径以及一个替代方法(对我来说没有起作用):https://askubuntu.com/a/609199/327339