trphoenix
2025-09-01 8928cb833acfc4a5a3d696a48c6d3b5a5f280fc8
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="author" content="岱特智能科技(上海)有限公司" />
      <link rel="shortcut icon" href="../../../img/favicon.ico" />
    <title>配置网络 - DT-HA</title>
    <link rel="stylesheet" href="../../../css/theme.css" />
    <link rel="stylesheet" href="../../../css/theme_extra.css" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/github.min.css" />
    
      <script>
        // Current page data
        var mkdocs_page_name = "\u914d\u7f6e\u7f51\u7edc";
        var mkdocs_page_input_path = "Usages\\netconfig\\netconfig.md";
        var mkdocs_page_url = null;
      </script>
    
    <!--[if lt IE 9]>
      <script src="../../../js/html5shiv.min.js"></script>
    <![endif]-->
      <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
      <script>hljs.highlightAll();</script> 
</head>
 
<body class="wy-body-for-nav" role="document">
 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
    <div class="wy-side-scroll">
      <div class="wy-side-nav-search">
          <a href="../../.." class="icon icon-home"> DT-HA
        </a><div role="search">
  <form id ="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
      <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" title="Type search term here" />
  </form>
</div>
      </div>
 
      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul>
                <li class="toctree-l1"><a class="reference internal" href="../../..">首页</a>
                </li>
              </ul>
              <ul>
                <li class="toctree-l1"><a class="reference internal" href="../../../about/">关于</a>
                </li>
              </ul>
              <p class="caption"><span class="caption-text">使用教程</span></p>
              <ul class="current">
                  <li class="toctree-l1"><a class="reference internal" href="../../../install-guide/installHa/">安装</a>
                  </li>
                  <li class="toctree-l1 current"><a class="reference internal current" >使用</a>
    <ul class="current">
                <li class="toctree-l2"><a class="reference internal" href="../../usage/">使用概述</a>
                </li>
                <li class="toctree-l2 current"><a class="reference internal current" href="#">配置网络</a>
    <ul class="current">
    <li class="toctree-l3"><a class="reference internal" href="#_2">熟悉网络配置命令</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#_3">配置网络</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#_4">在系统安装好初始化完成后配置网络</a>
    </li>
    </ul>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../initConfig/initConfig/">系统初始化配置</a>
                </li>
    </ul>
                  </li>
                  <li class="toctree-l1"><a class="reference internal" >Q/A</a>
    <ul>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E9%80%8F%E6%9E%90%E4%B8%AD%E5%BF%83HA%E7%8E%AF%E5%A2%83%E6%B8%A9%E5%BA%A6%E5%8F%91%E9%80%81%E5%88%B0%E8%83%9C%E9%80%8F%E7%9A%84%E6%93%8D%E4%BD%9C%E6%8C%87%E5%8D%97/">透析中心HA环境温度发送到胜透的操作指南</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/errorsQA/">errorsQA</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/HA-%E5%A6%82%E4%BD%95%E5%AE%9E%E7%8E%B0%E7%8A%B6%E6%80%81%E5%8F%8D%E8%BD%AC/">HA-如何实现状态反转</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/TS88%E9%80%8F%E6%9E%90%E6%9C%BA%E8%81%94%E6%9C%BA%E9%80%9A%E4%BF%A1-%E4%B8%AD%E6%96%87%E7%89%88/">TS88透析机联机通信-中文版</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/VMware-ESXi%E6%89%A9%E5%B1%95HomeAssistant%E7%A1%AC%E7%9B%98%E6%8C%87%E5%8D%97/">VMware-ESXi扩展HomeAssistant硬盘指南</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%A6%82%E4%BD%95%E9%9B%86%E6%88%90%E5%92%8C%E9%A3%8E%E5%A4%A9%E6%B0%94%E7%BB%84%E4%BB%B6%E5%88%B0HA/">如何集成和风天气组件到HA</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%A6%82%E5%8E%95%E9%A3%8E%E9%99%A9-%E4%BA%BA%E5%AD%98%E5%9C%A8%E4%BC%A0%E6%84%9F%E5%99%A8%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95/">如厕风险-人存在传感器配置方法</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/ubunte-desktop%E6%A1%8C%E9%9D%A2%E7%B3%BB%E7%BB%9F%E5%A6%82%E4%BD%95%E9%85%8D%E7%BD%AE%E5%BC%80%E5%90%AF%E8%BF%9C%E7%A8%8B%E5%8D%8F%E5%8A%A9/">Ubuntu-desktop桌面系统如何配置开启远程协助</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%A6%82%E4%BD%95%E7%A6%BB%E7%BA%BF%E5%AE%89%E8%A3%85Docker%28ubunt24.04%29/">如何离线安装Docker(ubuntu24.04)</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%A6%82%E4%BD%95%E5%9C%A8%E7%BA%BFDocker%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85%E8%A3%85HomeAssistant/">如何在线Docker一键安装HomeAssistant</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%A6%82%E4%BD%95%E7%A6%BB%E7%BA%BFDocker%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85HomeAssistant/">如何离线Docker一键安装HomeAssistant</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../QA/%E5%9F%BA%E4%BA%8EDocker%E7%9A%84%E6%96%B9%E5%BC%8F%E5%AE%89%E8%A3%85HomeAssistant/">基于Docker的方式安装HomeAssistant</a>
                </li>
    </ul>
                  </li>
              </ul>
              <p class="caption"><span class="caption-text">其它教程</span></p>
              <ul>
                  <li class="toctree-l1"><a class="reference internal" >Node-red相关</a>
    <ul>
                <li class="toctree-l2"><a class="reference internal" href="../../../node-reds/%E5%AE%89%E8%A3%85node-red%E8%AE%B0%E5%BD%95/">安装node-red记录</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../../node-reds/%E5%A6%82%E4%BD%95%E6%8A%8Anode-red%E5%AE%89%E8%A3%85%E5%88%B0orangepiZero3/">如何把node-red安装到orangepiZero</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../../node-reds/ModbusPoll-v7.0.0%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B/">ModbusPoll-v7.0.0使用教程</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../../node-reds/node-red%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6%E5%88%97%E8%A1%A8/">node-red常用组件列表</a>
                </li>
                <li class="toctree-l2"><a class="reference internal" href="../../../node-reds/node-red%E5%A6%82%E4%BD%95%E8%BF%9E%E6%8E%A5modbus%20_slave%E8%AE%BE%E5%A4%87/">node-red如何连接modbus _slave设备</a>
                </li>
    </ul>
                  </li>
              </ul>
      </div>
    </div>
    </nav>
 
    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      <nav class="wy-nav-top" role="navigation" aria-label="Mobile navigation menu">
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../..">DT-HA</a>
        
      </nav>
      <div class="wy-nav-content">
        <div class="rst-content"><div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../../.." class="icon icon-home" aria-label="Docs"></a></li>
          <li class="breadcrumb-item">使用教程</li>
          <li class="breadcrumb-item">使用</li>
      <li class="breadcrumb-item active">配置网络</li>
    <li class="wy-breadcrumbs-aside">
    </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
            <div class="section" itemprop="articleBody">
              
                <h2 id="_1">配置网络<a class="headerlink" href="#_1" title="Permanent link">&para;</a></h2>
<p>公司使用的X86小工控机,大多有多个网卡,一般一个无线网卡,两个有线网卡.多数情况下,我们可能是使用的WIFI网络,这样比较方便,有时为了HA提供的服务折稳定性,我们尽量使用LAN线网络,避免无线网信号质量的问题。所以就涉及到配网的问题。</p>
<p>HomeAssistant的网络配置,在系统没有安装成功之前,不能通过web进入网页界面时,配置网络只能通过自带网络配置命令来进行.</p>
<h4 id="_2">熟悉网络配置命令<a class="headerlink" href="#_2" title="Permanent link">&para;</a></h4>
<p>HomeAssistant Cli 提供了默信折network配置命令如下:</p>
<div class="codehilite"><pre><span></span><code>ha netWork
Useage:
    ha network [command]
Examples:
    ha network info
    ha network interface options
Available Commands:
    info Shows information about the host network
    reload Reload Network information the host
    scan Scan for Access Points on a wireless interface.
    update Update settings of a network interface
    vlan Create a new VLAN on an ethernet interface
Flags:
    -h, --help help for network
Global Flags:
    --api-token string Home Assistant Supervisor API token
    --config string Optional config file (default is $HOME/.homeassistant.yaml)
    --endpoint string Endpoint for Home Assistant Supervisor (default is&#39;supervisor&#39;)
    --log-level string Log level (defaults to Warn)
    --no-progress Disable the progress spinner
    --raw-json Output raw JSON from the API
Use &quot;ha network [command] --help&quot; for more information about a command.
</code></pre></div>
 
<p>这个ha network命令,大约如下几个功能</p>
<ul>
<li>info 显示网络配置信息</li>
<li>reload 重新加载网络</li>
<li>scan 扫描网络</li>
<li>update 配置网络</li>
</ul>
<p>我们在使用这个命令时,可以使用其简写,比如省去前面的ha,还可以省去后面的work
比如,我们想查看网络配置信息,可以用如下命令来进行</p>
<div class="codehilite"><pre><span></span><code>net info
</code></pre></div>
 
<p>这条命令就会把所有的网络配置信息全部显示出来,只是如果网卡较多,我们没有法在一屏全部阅读完,所以这就引发另一个问题.netwrok所有的子命令,后面都是可以或必须跟着操作对像来进行的,具体的就是,操作或显示哪个网卡接口.一般情况下是如下型式</p>
<div class="codehilite"><pre><span></span><code>net [command] [interface]
net [子命令] [网卡名称]
</code></pre></div>
 
<p>那么如何查看网卡名称呢,在haos 的cli控制台界面,任意时间,同时按下 <strong><em>ctrl+c</em></strong>  后,ha的界面返回到待机界面,如下图所示.</p>
<p><img alt="网卡接口待机图" src="https://dhcdn.leon056.com/bpfStudy/docs/20250416112808034.png" /></p>
<p>图中共显示了三个网卡接口:</p>
<ul>
<li>wlp3s0 这个是无线网卡接口的名称,一般情况下w字符打头的我为无线网卡</li>
<li>enp2s0 这个对应小主机上就是LNA1,有线网卡1的名称</li>
<li>enp4s0 这个对应小主机上就是LNA2,有线网卡1的名称</li>
</ul>
<p>查看到了这三个网卡名称,我们就可以对网卡进行查看信息配置等.</p>
<p>对有初装的HAOS还有准备进行Udate的小主机,最好,就是在路由器端<em>默认提供科学上网</em> ,否则在新安装折初始化那里就会被永远卡住,无法安装成功,如果是自动更新,那么将会更新失败.</p>
<h4 id="_3">配置网络<a class="headerlink" href="#_3" title="Permanent link">&para;</a></h4>
<p>一般情况下,对于enp2s0,enp4s0,如果路由器端提供了自动获取IP地址功能,则无需配置,网线插入即可使用。</p>
<p>但是对于比较复杂的网络则需要配置,同样,如果想使用wifi网络,也需要配置 .</p>
<p>配置网络的命令如下:</p>
<div class="codehilite"><pre><span></span><code>ha &gt; net update
Usage:
  ha network update [interface] [flags]
Aliases:
  update, set, up
Examples:
  ha network update eth0 --ipv4-method auto --ipv6-method disabled
Flags:
  -e, --disabled                   Disable interface
  -h, --help                       help for update
      --ipv4-address stringArray   IPv4 address for the interface in the 192.168.1.5/24
      --ipv4-gateway string        The IPv4 gateway the interface should use
      --ipv4-method string         Method on IPv4: static|auto|disabled
      --ipv4-nameserver stringArray IPv4 address of upstream DNS servers. Use multiple times for multiple servers.
      --ipv6-address stringArray   IPv6 address for the interface in the 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64
      --ipv6-gateway string        The IPv6 gateway the interface should use
      --ipv6-method string         Method on IPv6: static|auto|disabled
      --ipv6-nameserver stringArray IPv6 address for upstream DNS servers. Use multiple times for multiple servers.
      --wifi-auth string           Used authentication: open, wep, wpa-psk
      --wifi-mode string           Wifi mode: infrastructure, adhoc, mesh or ap
      --wifi-psk string            Shared authentication key for wep or wpa
      --wifi-ssid string           SSID for wifi connection
Global Flags:
      --api-token string           Home Assistant Supervisor API token
      --config string              Optional config file (default is $HOME/.homeassistant.yaml)
      --endpoint string            Endpoint for Home Assistant Supervisor (default is `supervisor`)
      --log-level string           Log level (defaults to Warn)
      --no-progress                Disable the progress spinner
      --raw-json                   Output raw JSON from the API
</code></pre></div>
 
<p>这条命令ha network update [interface] [flags],提供了很多功能,它可以配置wif网络,可以对指定的网卡配置ip4/6的IP地址,网关,是否启用等.因此可以在实际工作中灵活使用.
具体用法简译如下</p>
<div class="codehilite"><pre><span></span><code>ha &gt; net update
Usage:
  ha network update [interface] [flags]
Aliases:
  update, set, up
Examples:
  ha network update eth0 --ipv4-method auto --ipv6-method disabled
Flags:
  -e, --disabled                   禁用接口
  -h, --help                       显示更新的帮助信息
      --ipv4-address stringArray   接口的 IPv4 地址,例如 192.168.1.5/24
      --ipv4-gateway string        接口使用的 IPv4 网关
      --ipv4-method string         IPv4 方法: static|auto|disabled
      --ipv4-nameserver stringArray 上游 DNS 服务器的 IPv4 地址,可多次使用以指定多个服务器
      --ipv6-address stringArray   接口的 IPv6 地址,例如 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64
      --ipv6-gateway string        接口使用的 IPv6 网关
      --ipv6-method string         IPv6 方法: static|auto|disabled
      --ipv6-nameserver stringArray 上游 DNS 服务器的 IPv6 地址,可多次使用以指定多个服务器
      --wifi-auth string           使用的认证方式: open, wep, wpa-psk
      --wifi-mode string           WiFi 模式: infrastructure, adhoc, mesh 或 ap
      --wifi-psk string            WEP 或 WPA 的共享认证密钥
      --wifi-ssid string           WiFi 连接的 SSID
 
Global Flags:
      --api-token string           Home Assistant Supervisor API 令牌
      --config string              可选的配置文件路径(默认值为 $HOME/.homeassistant.yaml)
      --endpoint string            Home Assistant Supervisor 的端点(默认值为 `supervisor`)
      --log-level string           日志级别(默认值为 Warn)
      --no-progress                禁用进度条
      --raw-json                   以原始 JSON 格式输出 API 数据
 
FATA[0000] Error while executing rootCmd: accepts 1 arg(s), received 0
</code></pre></div>
 
<p>下面,我们就以配置wifi联接到网络为例说明一下:</p>
<p>比如我们默认的WIFI热点如下:</p>
<div class="codehilite"><pre><span></span><code>wifi info:
ssid:DT_IoT_GateWay
passWord:HnczjTyrb0
</code></pre></div>
 
<p>那根据我们上文查看到的无线网卡的名称:<strong>wlp3s0</strong> </p>
<p>我们使用如下配置命令,来让haos小工控机联上wifi网络:</p>
<div class="codehilite"><pre><span></span><code>ha network update wlp3s0 --wifi-auth wpa-psk --wifi-psk &quot;HmczjTYrb0&quot; --wifi-mode infrastructure --wifi-ssid &quot;DT_IoT_GateWay&quot; --ipv4-method auto --ipv6-method disabled
</code></pre></div>
 
<p>这条命令解释如下:</p>
<ul>
<li>指定wifi的密码方式为:wpa-psk (--wifi-auth wpa-psk).</li>
<li>指定wif的密码为:HnczjTyrb0 (--wifi-psk "HmczjYrb0").</li>
<li>指定网卡接口模式为:infrastructure 即常规模式 (--wifi-mode infrastructure).</li>
<li>指定要联接的网络SSID:DT_IoT_GateWay (--wifi-ssid "DT_IoT_GateWay").</li>
<li>指定IP地址获取方式(静态、自动、禁用):自动 ( --ipv4-method auto).</li>
<li>指定是否禁用IpV6:禁用 (--ipv6-method disabled)</li>
</ul>
<p>如下图所示,我们成功的使用这条指令,配置好了wifi网络:</p>
<p><img alt="" src="https://dhcdn.leon056.com/bpfStudy/docs/20250416115724085.png" /></p>
<p>如下所示,配网成功后,路由器已自动为其分配好了ip地址:</p>
<p><img alt="" src="https://dhcdn.leon056.com/bpfStudy/docs/20250416115834649.png" /></p>
<p>此时,我们在浏览器中输入网址<a href="http://192.168.3.2:8123">http://192.168.3.2:8123</a> 即可进入haos的web页面.</p>
<p>下图是无线网卡与有线网卡同时启用的情况,可以看到,两个网卡都被正确的分配到了IP地址:</p>
<p><img alt="" src="https://dhcdn.leon056.com/bpfStudy/docs/20250416120009156.png" /></p>
<h4 id="_4">在系统安装好初始化完成后配置网络<a class="headerlink" href="#_4" title="Permanent link">&para;</a></h4>
<p>系统初始化完成后,仍然可以调整配置网络,</p>
<p>设置-系统-网络 中配置网络接口可以进行网络配置</p>
<p><img alt="" src="https://dhcdn.leon056.com/bpfStudy/docs/20250417101928366.png" /></p>
<p>在这里你可以看到我们的三块网卡,wlp3s0,enp2s0,enp4s0,可在此处配置,每个网卡的IP,子网,网关,DNS等,也可以配置wi-fi热点.</p>
              
            </div>
          </div><footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="Footer Navigation">
        <a href="../../usage/" class="btn btn-neutral float-left" title="使用概述"><span class="icon icon-circle-arrow-left"></span> Previous</a>
        <a href="../../initConfig/initConfig/" class="btn btn-neutral float-right" title="系统初始化配置">Next <span class="icon icon-circle-arrow-right"></span></a>
    </div>
 
  <hr/>
 
  <div role="contentinfo">
    <!-- Copyright etc -->
  </div>
 
  Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
          
        </div>
      </div>
 
    </section>
 
  </div>
 
  <div class="rst-versions" role="note" aria-label="Versions">
  <span class="rst-current-version" data-toggle="rst-current-version">
    
        <span>
          <a href="http://dh.leon056.com:7499/r/Embedded/HomeAssistantPtoject.git" class="fa fa-code-fork" style="color: #fcfcfc"> Dh</a>
        </span>
    
    
      <span><a href="../../usage/" style="color: #fcfcfc">&laquo; Previous</a></span>
    
    
      <span><a href="../../initConfig/initConfig/" style="color: #fcfcfc">Next &raquo;</a></span>
    
  </span>
</div>
    <script src="../../../js/jquery-3.6.0.min.js"></script>
    <script>var base_url = "../../..";</script>
    <script src="../../../js/theme_extra.js"></script>
    <script src="../../../js/theme.js"></script>
      <script src="../../../search/main.js"></script>
    <script>
        jQuery(function () {
            SphinxRtdTheme.Navigation.enable(true);
        });
    </script>
 
</body>
</html>