<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wi-Fi相关文章列表 | 皇家元林</title>
	<atom:link href="https://hjyl.org/tags/wi-fi/feed/" rel="self" type="application/rss+xml" />
	<link>https://hjyl.org</link>
	<description>刘元林的个人博客</description>
	<lastBuildDate>Sat, 21 Sep 2024 14:06:56 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://img.hjyl.org/uploads/2019/10/cropped-about-me-32x32.png</url>
	<title>Wi-Fi相关文章列表 | 皇家元林</title>
	<link>https://hjyl.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>笔记本安装PVE入坑</title>
		<link>https://hjyl.org/notebook-pve-only-wifi/</link>
					<comments>https://hjyl.org/notebook-pve-only-wifi/#comments</comments>
		
		<dc:creator><![CDATA[皇家元林]]></dc:creator>
		<pubDate>Sat, 21 Sep 2024 14:06:54 +0000</pubDate>
				<category><![CDATA[元林手札]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[PVE]]></category>
		<category><![CDATA[Wi-Fi]]></category>
		<category><![CDATA[无线网卡]]></category>
		<category><![CDATA[笔记本]]></category>
		<guid isPermaLink="false">https://hjyl.org/?p=5355</guid>

					<description><![CDATA[昨天的昨天，也就是前天晚上，爆肝到凌晨三点多，我告诉自己再不睡觉，天就要亮了，而且当天还得上班。还好上班一点都 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>昨天的昨天，也就是前天晚上，爆肝到凌晨三点多，我告诉自己再不睡觉，天就要亮了，而且当天还得上班。还好上班一点都没犯困，下班回来，吃过饭就困的不行。</p>



<p>三年前，我买了一款<a href="https://hjyl.org/notebook-of-1111/">Thinkpad笔记本</a>，当时我们公司时不时还需要考证，都是些没用的证，譬如三级会展设计师，但是可以补助2000块，而且考试也是走走形式。而考试需要带笔记本，甭管好的坏的都行。于是我就买了个二手的。从那以后，我这台电脑就一直在吃灰了，因为我又买了个pad，基本上够用了。最近fnos不是很火嘛，这一看不得了，所有app都给我推这个视频文章之类的。所以我想折腾一下，顺便试试PVE，以前用esxi感觉不错，除了驱动有限制，用起来还是很顺手的，只是后来把我硬盘搞坏掉之后，再也不想用了。或许是我硬盘的问题，不管了。</p>



<p>pve和fnos一样，都是基于Debian开发的，我对Debian的印象还是不错的，我的服务器系统都是用Debian的，就是软件库的版本跟不上，相比之下，Fedora就比较新一些。</p>



<p>那么言归正传只有无线网卡的笔记本怎么安装pve，然后联网呢？</p>



<p>安装是比较顺利的，也很快。起先我以为选择无线网卡就可以像其他主机一样，可以网桥虚拟机，正常的联网呢，但是无线网卡不行。找了很多资料，配置相当复杂。我来总结记录一下。</p>



<h3 class="wp-block-heading">#需要联网</h3>



<p>额，没错，连不上网，还得需要联网，咋弄？还好我有USB网卡，插上之后，笔记本上登录pve的控制台，使用“ip a”命令可以看到你的网卡情况，这时你可以在插拔之间，看到USB网卡的名字。然后</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash line-numbers">cp /etc/network/interfaces /etc/network/interfaces.bak</code></pre>



<p>备份一下/etc/network/interfaces配置，万一出问题了还能恢复。然后</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash line-numbers">nano /etc/network/interfaces</code></pre>



<p>编辑配置，加上USB网卡的配置：</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">auto enxf01e546328eb
iface enxf01e546328eb inet dhcp
#enxf01e546328eb是你网卡名称，一般有线网卡都是en开头的</code></pre>



<p>但是问题来了，我没有USB网卡怎么办？人家说手机USB也能共享网络，这个我没试过可以自行试之。就是将上面配置的网卡名称改成对应的USB即可。譬如：</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">auto usb0
iface usb0 inet dhcp</code></pre>



<h3 class="wp-block-heading">#安装无线网卡驱动</h3>



<p>我这个没特别安装，或许核心自带驱动，所以跳过此步骤，我就假装我这笔记本无需另外安装网卡驱动。然而就是要特别需要安装BCM4360和RTL88x2bu网卡驱动的可以参考如下文章：</p>



<p><a href="https://hjyl.org/go/aHR0cHM6Ly93d3cuamlhbnNodS5jb20vcC84YzY4NGQxMWJhZjA=" rel="nofollow" target="_blank">https://www.jianshu.com/p/8c684d11baf0</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly91bml4LnN0YWNrZXhjaGFuZ2UuY29tL3F1ZXN0aW9ucy8xNzU4MTAvaG93LXRvLWluc3RhbGwtYnJvYWRjb20tYmNtNDM2MC1vbi1kZWJpYW4tb24tbWFjYm9vay1wcm8=" rel="nofollow" target="_blank">https://unix.stackexchange.com/questions/175810/how-to-install-broadcom-bcm4360-on-debian-on-macbook-pro</a></p>



<p><a href="https://hjyl.org/go/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpeGlmdW4vYXJ0aWNsZS9kZXRhaWxzLzEyNTQ1MjM4Mg==" rel="nofollow" target="_blank">https://blog.csdn.net/lixifun/article/details/125452382</a></p>



<h3 class="wp-block-heading">#安装wpasupplicant</h3>



<pre class="wp-block-code"><code lang="bash" class="language-bash line-numbers">apt update &amp;&amp; apt install wpasupplicant</code></pre>



<p>因为无线Wi-Fi是使用wpa/wpa2加密的，想连接这种加密的wifi需要wpasupplicant支持。然后修改/etc/network/interfaces文件，添加无线接口配置：</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">auto wlp4s0
iface wlp4s0 inet dhcp
        wpa-ssid 你的wifi名称
        wpa-psk 你的wifi密码</code></pre>



<p>然后通过“ifup wlp4s0”命令激活连接WiFi网络。或者重启网络。</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash line-numbers">service networking restart
systemctl restart networking.service</code></pre>



<p>无意外的话，应该成功连上Wi-Fi了，可以删除/etc/network/interfaces文件中usb0配置了。也可以通过分配的IP地址访问pve的web界面了。通过“ip a”可以查IP。</p>



<h3 class="wp-block-heading">#安装DHCP服务器</h3>



<p>因为无线网卡不能直接网桥，所以虚拟机不能分配到IP，需要安装DHCP服务器分配IP地址。</p>



<pre class="wp-block-code"><code lang="bash" class="language-bash line-numbers"># 安装dhcp服务器
apt install isc-dhcp-server
# 备份一下默认的配置
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak</code></pre>



<p>编辑/etc/dhcp/dhcpd.conf文件，填入以下内容新建一个子网，网段和虚拟网桥的网段；dns是我的主路由和一个公共dns；routers 是虚拟网桥的地址，注意虚拟网桥的地址设置为10.3.3.1/24而不是10.3.3.1/32，否则网络不能经过网桥转发。</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">subnet 10.3.3.0 netmask 255.255.255.0 {
  range 10.3.3.10 10.3.3.99;
  option domain-name-servers 192.168.0.1, 223.5.5.5;
  option routers 10.3.3.1;
}</code></pre>



<p>给vmbr0指定dhcp服务，修改/etc/default/isc-dhcp-server文件如下，</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">INTERFACESv4=”vmbr0″</code></pre>



<p>使用service isc-dhcp-server restart启动dhcp服务。</p>



<h3 class="wp-block-heading">#虚拟机访问外网</h3>



<p>修改/etc/network/interfaces，设置下网络配置，使用iptables命令添加转发规则，把所有的请求都通过无线网卡转发出去。</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">auto lo
iface lo inet loopback
# 默认的网络
iface enp4s0 inet manual
# 如果你有有线网络，可能就像这样
auto wlp4s0
iface wlp4s0 inet dhcp
        wpa-ssid xxxx
        wpa-psk xxxxxxxx
# 无线网络配置
auto vmbr0
iface vmbr0 inet static
        address 10.3.3.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0
# pve网桥虚拟网卡vmbr0配置
post-up iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -o wlp4s0 -j MASQUERADE
# 转发流量到无线网卡</code></pre>



<h3 class="wp-block-heading">#打开系统转发的功能</h3>



<p>这是最最最关键的一步，前面设置好，WiFi是正常的，虚拟机dhcp也是正常的，但是虚拟机访问不了外面，就是这步的问题。这相当于一个总开关，修改/etc/sysctl.conf把其中net.ipv4.ip_forward=1的注释去掉，然后执行sysctl -p使配置生效。好了，网络都正常了。</p>



<p>但是问题来了，我这192的局域网怎么访问10的局域网呢？</p>



<div class="wp-block-group is-style-hmd-border has-cool-to-warm-spectrum-gradient-background has-background"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p>在<a href="https://hjyl.org/go/aHR0cHM6Ly93d3cuamlhbnNodS5jb20vcC84YzY4NGQxMWJhZjA=" rel="nofollow" target="_blank">这篇文章</a>里介绍用静态路由的方法。</p>



<p>第一步，在静态路由中添加一条规则，接口填LAN，目标10.3.3.0/24，网关192.168.0.110。这样当路由器下的设备访问10.3.3.0/24时，请求就会到192.168.0.110。<br>第二步，添加一条iptables规则就好了，还是直接上/etc/network/interfaces文件：</p>



<pre class="wp-block-code"><code lang="toml" class="language-toml line-numbers">auto lo
iface lo inet loopback

iface enp4s0 inet dhcp

auto wlp4s0
iface wlp4s0 inet dhcp
        wpa-ssid xxxx
        wpa-psk xxxxxxxx

auto vmbr0
iface vmbr0 inet static
        address 10.3.3.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

post-up iptables -t nat -A POSTROUTING -o wlp4s0 -j MASQUERADE;iptables -t nat -A POSTROUTING -d 10.3.3.0/24 -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -o wlp4s0 -j MASQUERADE; iptables -t nat -D POSTROUTING -d 10.3.3.0/24 -o vmbr0 -j MASQUERADE</code></pre>
</div></div>



<p>上面这个方法可以试试，我没试过，因为我的路由器没有静态路由的功能。所以我只能在pve里装了个win系统虚拟机。然后通过内网穿透实现互联。</p>



<p>参考链接：</p>



<p><a href="https://hjyl.org/go/aHR0cHM6Ly93d3cuamlhbnNodS5jb20vcC84YzY4NGQxMWJhZjA=" rel="nofollow" target="_blank">https://www.jianshu.com/p/8c684d11baf0</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly91bml4LnN0YWNrZXhjaGFuZ2UuY29tL3F1ZXN0aW9ucy8xNzU4MTAvaG93LXRvLWluc3RhbGwtYnJvYWRjb20tYmNtNDM2MC1vbi1kZWJpYW4tb24tbWFjYm9vay1wcm8=" rel="nofollow" target="_blank">https://unix.stackexchange.com/questions/175810/how-to-install-broadcom-bcm4360-on-debian-on-macbook-pro</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpeGlmdW4vYXJ0aWNsZS9kZXRhaWxzLzEyNTQ1MjM4Mg==" rel="nofollow" target="_blank">https://blog.csdn.net/lixifun/article/details/125452382</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly9jbG91ZC50ZW5jZW50LmNvbS9kZXZlbG9wZXIvYXJ0aWNsZS8xMzc0ODcz" rel="nofollow" target="_blank">https://cloud.tencent.com/developer/article/1374873</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly96aHVhbmxhbi56aGlodS5jb20vcC82NTY2NTI1Nzc=" rel="nofollow" target="_blank">https://zhuanlan.zhihu.com/p/656652577</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2hnX3poaC9hcnRpY2xlL2RldGFpbHMvMTQwNzM0Mjg5" rel="nofollow" target="_blank">https://blog.csdn.net/hg_zhh/article/details/140734289</a><br><a href="https://hjyl.org/go/aHR0cHM6Ly9ibG9nLnNreWp1LmNjL3Bvc3QvcHJveG1veC1pcHY0LW5hdC1pcHY2Lw==" rel="nofollow" target="_blank">https://blog.skyju.cc/post/proxmox-ipv4-nat-ipv6/</a></p>
<div id="content-copyright"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;font-size: 13px;">版权声明: </span><span style="font-size: 13px;">本文采用 <a href="https://hjyl.org/go/aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC8=" rel="nofollow" target="_blank">BY-NC-SA</a> 协议进行授权，如无注明均为原创，转载请注明转自 <a href="https://hjyl.org">皇家元林</a><br>本文链接: <a rel="bookmark" title="笔记本安装PVE入坑" href="https://hjyl.org/notebook-pve-only-wifi/">笔记本安装PVE入坑</a></span></div>]]></content:encoded>
					
					<wfw:commentRss>https://hjyl.org/notebook-pve-only-wifi/feed/</wfw:commentRss>
			<slash:comments>19</slash:comments>
		
		
			</item>
	</channel>
</rss>
