<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>KSM的兴趣小栈</title>
    <description>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.
</description>
    <link>/</link>
    <atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 15 Aug 2022 12:27:30 +0800</pubDate>
    <lastBuildDate>Mon, 15 Aug 2022 12:27:30 +0800</lastBuildDate>
    <generator>Jekyll v4.2.2</generator>
    
      <item>
        <title>中日字幕 | 花は揺れる/花枝摇曳 | adieu(上白石萌歌)</title>
        <description>&lt;p&gt;夏风虽然消散了春日的氤氲，却也演绎着记忆中的种种。很喜欢上白石萌歌的这首，花枝摇曳，在繁华的夏日中，往事如夏草一般在心间野蛮生长。
自制字幕，mv来源：https://www.youtube.com/watch?v=sC6H1WCYfyU&lt;/p&gt;

&lt;iframe width=&quot;100%&quot; height=&quot;450&quot; src=&quot;//player.bilibili.com/player.html?bvid=BV1SX4y1w7d2&amp;amp;high_quality=1&amp;amp;page=1&quot; scrolling=&quot;no&quot; border=&quot;0&quot; frameborder=&quot;no&quot; framespacing=&quot;0&quot; allowfullscreen=&quot;true&quot;&gt;
&lt;/iframe&gt;
</description>
        <pubDate>Sat, 13 Aug 2022 00:00:00 +0800</pubDate>
        <link>/2022-08/%E8%8A%B1%E6%9E%9D%E6%91%87%E6%9B%B3.html</link>
        <guid isPermaLink="true">/2022-08/%E8%8A%B1%E6%9E%9D%E6%91%87%E6%9B%B3.html</guid>
        
        
        <category>adieu</category>
        
      </item>
    
      <item>
        <title>pykalman使用教程</title>
        <description>&lt;h2 id=&quot;kalman-smoother--kalman-filter&quot;&gt;kalman smoother &amp;amp; kalman filter&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;相关参数&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;对应参数&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;initial conditions&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;initial_state_mean and initial_state_covariance&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;transition parameters&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;transition_matrices, transition_offsets(主要用于传递时变信息), transition_covariance&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;observation parameters&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;observation_matrices, observation_offsets, observation_covariance&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;初始值：一维数组赋予0，二维数组赋予单位矩阵&lt;/p&gt;

&lt;h2 id=&quot;一维时参数参与初始化的过程理解参数的含义&quot;&gt;一维时参数参与初始化的过程（理解参数的含义）&lt;/h2&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;scipy.stats&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;norm&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;states&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_timesteps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_dim_state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;measurements&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zeros&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_timesteps&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n_dim_obs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_timesteps&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;norm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rvs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initial_state_mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;initial_state_covariance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;measurements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
          &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;observation_matrices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;observation_offsets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;norm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rvs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;observation_covariance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition_matrices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;transition_offsets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;norm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rvs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;transition_covariance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;measurements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;observation_matrices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;observation_offsets&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;norm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rvs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;observation_covariance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;离线更新采用smooth或filter方法&quot;&gt;离线更新，采用smooth或filter方法&lt;/h2&gt;
&lt;h3 id=&quot;1定义kalman滤波器参数&quot;&gt;1、定义kalman滤波器参数&lt;/h3&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;KalmanFilter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;transition_matrices&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;delta_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]],&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;#系统矩阵
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;transition_offsets&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#类似于输入矩阵与输入的乘积，注意格式，
&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;#如有三个状态量就写成[0, 0, 0]
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;transition_covariance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#模型协方差
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;observation_matrices&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#观测矩阵，仅有一个观测量
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;observation_offsets&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#类似，因为只有一个观测量
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;observation_covariance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#观测协方差
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;initial_state_mean&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#以下两项用于定义初始的状态
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;initial_state_covariance&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;em_vars&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'transition_matrices'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'observation_matrices'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
						  &lt;span class=&quot;s&quot;&gt;'transition_offsets'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'observation_offsets'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
						  &lt;span class=&quot;s&quot;&gt;'transition_covariance'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'observation_covariance'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
						  &lt;span class=&quot;s&quot;&gt;'initial_state_mean'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'initial_state_covariance'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;#em_vars用于定义应用em算法时，对那些参数进行训练
&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;#如:em_vars=['transition_covariance','observation_covariance']
&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;#代表仅对这两个参数进行训练
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;2em训练kalman滤波器参数可选&quot;&gt;2、em训练kalman滤波器参数（可选）&lt;/h3&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;em&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#这里填测量值序列
&lt;/span&gt;	&lt;span class=&quot;n&quot;&gt;em_vars&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#效果同在滤波器内的定义
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;3进行滤波并得到后验估计&quot;&gt;3、进行滤波并得到后验估计&lt;/h3&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filtered_state_means&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;filtered_state_covariances&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;smoothed_state_means&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;smoothed_state_covariances&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;smooth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#等式左侧的两个参数分别代表后验状态、后验协方差；每行代表一个时刻的多个状态；
#行数代表有多少个时刻
#等式右侧的参数z，代表测量值的序列
#默认下推荐用smooth，其比filter更平滑，而且与其拥有相似的均值与方差
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;实现代码：
&lt;a href=&quot;:/637f7534cfc24f7b8495f68b0d936aa2&quot;&gt;pykalman_smooth_filter.py&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;在线更新采用filter_update方法&quot;&gt;在线更新，采用filter_update方法&lt;/h2&gt;
&lt;h3 id=&quot;普通在线更新&quot;&gt;普通在线更新&lt;/h3&gt;
&lt;p&gt;步骤一与smooth及filter的第一步相同，都是先定义kalman的参数。
第二个步骤即可进行在线更新，方法如下：&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cov_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filter_update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cov_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;observation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# x_kalman, cov_kalman分别代表上一状态以及上一状态的协方差，
# 格式分别为(n_dim_state)、(n_dim_state，n_dim_state)。
# z[i]代表最新时刻的观测值，格式为（n_dim_obs）
# 输出x_kalman, cov_kalman的格式分别为(n_dim_state)、(n_dim_state，n_dim_state)。
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;实现代码：&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;:/c8621ac6dff84e45b7577ff0a93cd6d7&quot;&gt;pykalman_update_filter.py&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;在smooth或filter的基础上更新&quot;&gt;在smooth或filter的基础上更新&lt;/h3&gt;
&lt;p&gt;步骤一与smooth及filter的第一步、第二步（可选）、第三步相同。
步骤二如下：&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cov_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cov_kalman1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filter_update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cov_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 利用最新的观测值100进行更新，并输入最后一个时刻的均值x_kalman[-1]，以及
# 协方差cov_kalman[-1]。输出x_kalman1, cov_kalman1的形状分别为(2,),(2,2)
&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#以下分别对t_space_a、x_kalman、z进行了拼接，方便绘图
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_space_a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;concatenate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_space&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t_space&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;delta_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]])&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;x_kalman1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_kalman1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;concatenate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_kalman&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_kalman1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iter_n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;z_a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;concatenate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;reshape&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iter_n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://pykalman.github.io/#kalmanfilter&quot;&gt;官方文档&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 25 Aug 2021 00:00:00 +0800</pubDate>
        <link>/2021-08/pykalman%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B.html</link>
        <guid isPermaLink="true">/2021-08/pykalman%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B.html</guid>
        
        
        <category>kalman</category>
        
      </item>
    
      <item>
        <title>samba搭建私有云</title>
        <description>&lt;h2 id=&quot;samba配置文件&quot;&gt;samba配置文件&lt;/h2&gt;
&lt;p&gt;samba进程名称：smbd
samba配置文件：/etc/samba/smb.conf&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;global&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
	&lt;span class=&quot;n&quot;&gt;smb&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ports&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;445&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# samba默认的端口为139和445，一般优先用445
&lt;/span&gt;	
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 共享文件夹名
&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;comment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;share&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;folder&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;comment是对该共享的描述&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;可以是任意字符串&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mnt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;raid10&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path用来指定共享目录的路径&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;可以用&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;、&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m这样的宏来代替路径里的unix用户和客户机的Netbios名&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;用宏表示主要用于&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;homes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;共享域&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;例如&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;如果我们不打算用home段做为客户的共享&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;而是在&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;下为每个Linux用户以他的用户名建个目录&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;作为他的共享目&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;录&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;这样path就可以写成&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;用户在连接到这共享时具体的路径会被他的用户名代替&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;要注意这个用户名路径一定要存在&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;否则&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;客户机在访问时会找不到网络路径&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;同样&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;如果我们不是以用&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;户来划分目录&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;而是以客户机来划分目录&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;为网络上每台可以访问samba的机器都各自建个以它的netbios名的路径&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;作为不同机器的共享资源&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;就可以&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;这样写&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;browseable&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;browseable用来指定该共享是否可以浏览&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;writable&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;writable用来指定该共享路径是否可写&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;available&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;yes&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;available用来指定该共享资源是否可用&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;admin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;该共享的管理者&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;admin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users用来指定该共享的管理员&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;（&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;对该共享具有完全控制权限&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;）。&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;在samba&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;3.0&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;中&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;如果用户验证方式设置成&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;“&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;security&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;share&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;”&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;时&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;此项无效&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;例如&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;admin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;david&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sandy&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;（&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;多个用户中间用逗号隔开&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;）。&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;允许访问该共享的用户&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;说明&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users用来指定允许访问该共享资源的用户&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;例如&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;david&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dave&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tech&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;（&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;多个用户或者组中间用逗号隔开&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;，&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;如果要加入一个组就用&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;“&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;组名&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;”&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;表示&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;。）&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考链接：&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/weixin_40806910/article/details/81917077?ops_request_misc=&amp;amp;request_id=&amp;amp;biz_id=102&amp;amp;utm_term=samba&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-3-81917077.first_rank_v2_pc_rank_v29&amp;amp;spm=1018.2226.3001.4187&quot;&gt;Linux samba的配置和使用&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/weixin_40378804/article/details/78725229?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163111608516780366599537%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163111608516780366599537&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-5-78725229.first_rank_v2_pc_rank_v29&amp;amp;utm_term=mount+%E6%8C%82%E8%BD%BDsamba+%E5%9F%9F%E5%90%8D&amp;amp;spm=1018.2226.3001.4187&quot;&gt;linux系统之cifs文件的存储（samba）&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/ezreal_tao/article/details/99477194?ops_request_misc=&amp;amp;request_id=&amp;amp;biz_id=102&amp;amp;utm_term=ubuntu%20%E6%96%87%E4%BB%B6%E6%9C%8D%E5%8A%A1%E5%99%A8&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-7-99477194.first_rank_v2_pc_rank_v29&amp;amp;spm=1018.2226.3001.4187&quot;&gt;ubuntu系统搭建samba文件共享服务器&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;samba设置访问用户&quot;&gt;samba设置访问用户&lt;/h2&gt;
&lt;p&gt;用系统中的现存用户名，授予专用于samba的密码（用ksm账户举例）：
输入命令后，输入要创建的密码
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;smbpasswd -a ksm&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;参考链接：
&lt;a href=&quot;https://blog.csdn.net/zhangjianying/article/details/74937378?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163109355316780274179661%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163109355316780274179661&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-74937378.first_rank_v2_pc_rank_v29&amp;amp;utm_term=samba+%E9%85%8D%E7%BD%AE%E5%AF%86%E7%A0%81&amp;amp;spm=1018.2226.3001.4187&quot;&gt;配置samba的访问密码和用户名&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;挂载samba私有云&quot;&gt;挂载samba私有云&lt;/h2&gt;
&lt;h3 id=&quot;linux&quot;&gt;linux&lt;/h3&gt;
&lt;p&gt;1、需要先安装cifs-utils：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt install cifs-utils&lt;/code&gt;
2、然后运行mount命令进行挂载
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount -t cifs -o username=**用户名不需要引号**,password=**密码不需要引号**,port=445 //172.16.12.252/share /mnt/test/&lt;/code&gt;
挂载只能采用ip的方式（未验证）
注意：卸载方式为，mount /mnt/test（以步骤2中的挂载位子为例）&lt;/p&gt;

&lt;p&gt;参考链接：&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/unmobile/article/details/80666100?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163111541516780357286340%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163111541516780357286340&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-3-80666100.first_rank_v2_pc_rank_v29&amp;amp;utm_term=mount+%E6%8C%82%E8%BD%BDsamba+&amp;amp;spm=1018.2226.3001.4187&quot;&gt;linux挂载samba文件系统的方法&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.51cto.com/990487026/2050116&quot;&gt;Linux 指定端口挂载samba 亲测可用！&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;windows&quot;&gt;windows&lt;/h3&gt;
&lt;p&gt;打开资源管理器，点击&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;添加一个网络位置&lt;/code&gt;，输入\192.168.0.104\share&lt;/p&gt;

&lt;p&gt;参考链接：&lt;a href=&quot;https://blog.csdn.net/zhangna20151015/article/details/104360225?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163145383316780265428067%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163145383316780265428067&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-104360225.first_rank_v2_pc_rank_v29&amp;amp;utm_term=windows+%E6%8C%82%E8%BD%BDsamba&amp;amp;spm=1018.2226.3001.4187&quot;&gt;win挂载linux共享目录（samba）&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;注意：windows一般只支持默认的samba端口，非默认端口的方案如下：
&lt;a href=&quot;https://blog.csdn.net/rocson001/article/details/86717722&quot;&gt;继勒索病毒“永恒之蓝”445端口被封之后，在公网实现smb文件共享&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 13 May 2021 00:00:00 +0800</pubDate>
        <link>/2021-05/samba%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89%E4%BA%91.html</link>
        <guid isPermaLink="true">/2021-05/samba%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89%E4%BA%91.html</guid>
        
        
        <category>samba</category>
        
      </item>
    
      <item>
        <title>apache2配置虚拟主机</title>
        <description>&lt;h2 id=&quot;监听端口&quot;&gt;监听端口：&lt;/h2&gt;
&lt;p&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apache2/ports.conf&lt;/code&gt;中，添加以下语句&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Listen 80
# 监听80端口
Listen 8080
# 监听8080端口
# 可同时定义多条
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;虚拟主机&quot;&gt;虚拟主机：&lt;/h2&gt;
&lt;h3 id=&quot;配置文件设置&quot;&gt;配置文件设置&lt;/h3&gt;
&lt;p&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apache2/sites-available/test.conf(假设该目录下有配置文件000-default.conf、default-ssl.conf、test.conf [自己新建的] )&lt;/code&gt;中添加如下语句&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;VirtualHost&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;*:80&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
# 当客户端访问本机所用的域名ip及端口满足条件，采用该虚拟主机规则；
# 作用类似于判断条件（if）的作用：基于主机名的虚拟主机
        ServerName web1.com
# 当客户端访问本机所用的域名为web1.com时，采用该虚拟主机规则；
# 作用类似于判断条件（if）的作用：基于主机名的虚拟主机
        ServerAdmin webmaster@localhost
# 错误页面时显示的联系方式？
        DocumentRoot /var/www/web1
# 设置网站所在的目录
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;

# 可同时定义多条
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;配置文件生效&quot;&gt;配置文件生效&lt;/h3&gt;
&lt;p&gt;在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apache2/sites-available&lt;/code&gt;中的配置文件并不会生效，只有处于
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apache2/sites-enabled/&lt;/code&gt;中的配置文件才会生效。可以利用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a2dissite&lt;/code&gt;指令和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a2ensite&lt;/code&gt;指令对配置文件进行生效与失效操作。（生效的原理即为，在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sites-enabled/&lt;/code&gt;下建立配置文件的链接；失效的原理即为，删除&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sites-enabled/&lt;/code&gt;下的配置文件链接）&lt;/p&gt;

&lt;p&gt;1、执行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo a2dissite&lt;/code&gt;并选择要失效的配置文件&lt;/p&gt;

&lt;p&gt;2、执行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo a2ensite&lt;/code&gt;并选择要生效的配置文件&lt;/p&gt;

&lt;h2 id=&quot;参考链接&quot;&gt;参考链接：&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://docs.huihoo.com/apache/httpd/2.0-cn/index.html&quot;&gt;apache2官方文档&lt;/a&gt;
&lt;a href=&quot;https://blog.csdn.net/game2123456/article/details/53189714?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163048864616780255283904%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163048864616780255283904&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-53189714.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2+VirtualHost+&amp;amp;spm=1018.2226.3001.4187&quot;&gt;Apache2 VirtualHost的配置方法&lt;/a&gt;
&lt;a href=&quot;https://blog.csdn.net/qq_38232378/article/details/103281975?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163048864616780255283904%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163048864616780255283904&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-103281975.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2+VirtualHost+&amp;amp;spm=1018.2226.3001.4187&quot;&gt;Apache2.4配置VirtualHost&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/qq_41661918/article/details/88052557?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_utm_term~default-4.control&amp;amp;spm=1001.2101.3001.4242&quot;&gt;Ubuntu 如何修改 Apache2网站根目录和默认网页&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/jarthong/article/details/80821843?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163054375416780264072894%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163054375416780264072894&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-80821843.first_rank_v2_pc_rank_v29&amp;amp;utm_term=%E6%9F%A5%E7%9C%8Bapache%E7%89%88%E6%9C%AC&amp;amp;spm=1018.2226.3001.4187&quot;&gt;查看Apache的版本&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;documentrootdirectory与location的区别&quot;&gt;DocumentRoot、Directory与Location的区别&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot /var/www/web1&lt;/code&gt;
用于在&amp;lt;VirtualHost *:80&amp;gt;中定义虚拟主机根目录的位置
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;Directory /var/www/nextcloud/&amp;gt;&lt;/code&gt;表示
用于设置目录的属性，可以独立于&amp;lt;VirtualHost *:80&amp;gt;使用，DocumentRoot的功能是Directory的真子集&lt;/p&gt;
&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Location&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;/private&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
	Order Allow,Deny
	Deny from all
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Location&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Location与上两者均不同之处在于，其后面接的是网络请求的位置。如：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://ip或domain/private&lt;/code&gt;只有请求满足该格式，才会被执行。
而上面定义的location将拒绝一切&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://ip或domain/private&lt;/code&gt;格式的请求&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/DXCyber409/article/details/80942389?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163058488716780274198912%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163058488716780274198912&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-16-80942389.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2+Directory+&amp;amp;spm=1018.2226.3001.4187&quot;&gt;Apache中DocumentRoot和Directory的区别&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/liushu_it/article/details/18656281?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163058572216780357242082%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163058572216780357242082&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-18656281.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache+Directory+&amp;amp;spm=1018.2226.3001.4187&quot;&gt;apache配置Directory目录权限的一些配置&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/banjuan3729/article/details/101075716?utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.control&amp;amp;depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.control&quot;&gt;Apache的Directory配置指南&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Mon, 22 Mar 2021 00:00:00 +0800</pubDate>
        <link>/2021-03/apache2%E9%85%8D%E7%BD%AE%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA.html</link>
        <guid isPermaLink="true">/2021-03/apache2%E9%85%8D%E7%BD%AE%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%9C%BA.html</guid>
        
        
        <category>apache2</category>
        
      </item>
    
      <item>
        <title>apache2配置强制ssl连接的webdav</title>
        <description>&lt;h2 id=&quot;多网站对应单ssl证书&quot;&gt;多网站对应单ssl证书&lt;/h2&gt;

&lt;p&gt;1、启用ssl功能模块&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo a2enmod ssl&lt;/code&gt;
否则会报错：Invalid command ‘SSLEngine’, perhaps misspelled or defined by a module not included in the server configuration
参考链接：
&lt;a href=&quot;https://blog.csdn.net/demon37/article/details/84243295?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163115984916780264032309%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163115984916780264032309&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-14-84243295.first_rank_v2_pc_rank_v29&amp;amp;utm_term=Invalid+command+%27SSLEngine%27%2C+perhaps+misspelled+or+defined+by+a+module+not+included+in+the+server+configuration&amp;amp;spm=1018.2226.3001.4187&quot;&gt;apache2 ssl配置&lt;/a&gt;
2、创建配置文件
该配置文件应该放在/etc/apache2/sites-available/目录下
并在/etc/apache2/sites-enabled目录下创建软连接&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# 该配置文件需要配合在http://ip或domain/建站时，仍旧存在一些问题
# DavLockDB /var/www/mywebdav/DavLock
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VirtualHost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;443&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ServerAdmin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;#ServerName kasumiksm.com
&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SSLEngine&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 开启ssl认证
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;SSLProtocol&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;all&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SSLv2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SSLv3&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SSLCipherSuite&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;HIGH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RC4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MD5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aNULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eNULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EDH&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EXP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MEDIUM&lt;/span&gt; 
    &lt;span class=&quot;n&quot;&gt;SSLHonorCipherOrder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#指定证书相关文件路径
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;SSLCertificateFile&lt;/span&gt;      &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Apache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SSLCertificateKeyFile&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Apache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SSLCertificateChainFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Apache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_root_bundle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;crt&lt;/span&gt;
 
    &lt;span class=&quot;n&quot;&gt;DocumentRoot&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;www&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;#Alias /webdav /var/www/webdav  # 该语句只有配合
&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;#DocumentRoot、Directory才有用
&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Location&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;DAV&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;On&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 开启webdav功能
&lt;/span&gt;         &lt;span class=&quot;n&quot;&gt;Options&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Indexes&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MultiViews&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;AllowOverride&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;Order&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;allow&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;deny&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;allow&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;all&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;AuthType&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Basic&lt;/span&gt;
         &lt;span class=&quot;c1&quot;&gt;#登陆 WebDAV 使用的用户名，可修改
&lt;/span&gt;         &lt;span class=&quot;n&quot;&gt;AuthName&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;pi&quot;&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;AuthUserFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;apache2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;password&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;Require&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;valid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; 
     &lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Location&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
     &lt;span class=&quot;c1&quot;&gt;#ErrorLog /var/log/httpd/mywebdav_error.log
&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;#CustomLog /var/log/httpd/mywebdav_access.log common
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VirtualHost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;#将80的请求转至443，可以不用
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VirtualHost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;80&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; 
     &lt;span class=&quot;n&quot;&gt;ServerAdmin&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;root&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt; 
     &lt;span class=&quot;n&quot;&gt;ServerName&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;
     &lt;span class=&quot;n&quot;&gt;RewriteEngine&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# 启用重写
&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;#RewriteCond %{SERVER_PORT} !^443$ 
&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;RewriteCond&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;REQUEST_URI&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;^/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;?$&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;# 重写条件，%{REQUEST_URI}表示访问的相对地址，就是相对根目录的
&lt;/span&gt;	&lt;span class=&quot;c1&quot;&gt;# 地址，就是域名/后面的成分，格式上包括最前面的“/”
&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;#RewriteRule ^(.)$ https://%{SERVER_NAME}$1 [L,R]
&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;RewriteRule&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;
     &lt;span class=&quot;c1&quot;&gt;# 匹配所有字符串，并将其改写为后面的形式
&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;VirtualHost&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考链接：
&lt;a href=&quot;https://blog.csdn.net/yxwb1253587469/article/details/50604913?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163116449016780261952599%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163116449016780261952599&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-2-50604913.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2.4+rewrite%E8%A7%84%E5%88%99%E7%BC%96%E5%86%99&amp;amp;spm=1018.2226.3001.4187&quot;&gt;.htaccess中的apache rewrite规则写法详解&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;多网站对应多ssl证书&quot;&gt;多网站对应多ssl证书&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/a249130/article/details/82781951?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163101789616780271593889%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163101789616780271593889&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-3-82781951.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2+%E5%A4%9A%E4%B8%AAssl%E8%AF%81%E4%B9%A6&amp;amp;spm=1018.2226.3001.4187&quot;&gt;apache环境下配置多个ssl证书搭建多个站点&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/u010820857/article/details/89226799?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163101519016780366548773%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163101519016780366548773&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-89226799.first_rank_v2_pc_rank_v29&amp;amp;utm_term=apache2+%E9%83%A8%E7%BD%B2ssl%E8%AF%81%E4%B9%A6&amp;amp;spm=1018.2226.3001.4187&quot;&gt;ubuntu apache2 配置安装ssl证书,https&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://mp.weixin.qq.com/s?__biz=Mzg4MTYwMzY1Mw==&amp;amp;mid=2247495505&amp;amp;idx=1&amp;amp;sn=c45b2d758494ecf535f8411f3ddf316a&amp;amp;source=41#wechat_redirect&quot;&gt;Let’s Encrypt，免费好用的 HTTPS 证书&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Tue, 02 Feb 2021 00:00:00 +0800</pubDate>
        <link>/2021-02/apache2%E9%85%8D%E7%BD%AE%E5%BC%BA%E5%88%B6ssl%E8%BF%9E%E6%8E%A5%E7%9A%84webdav.html</link>
        <guid isPermaLink="true">/2021-02/apache2%E9%85%8D%E7%BD%AE%E5%BC%BA%E5%88%B6ssl%E8%BF%9E%E6%8E%A5%E7%9A%84webdav.html</guid>
        
        
        <category>apache2</category>
        
      </item>
    
      <item>
        <title>几种搭建内网穿透环境的方案及实现（二）：bind9搭建私有dns服务器并实现ddns</title>
        <description>&lt;p&gt;通过前面章节的介绍，我们了解了内网穿透的各种方案，本文将着重于利用bind9搭建的方式来实现内网穿透。整个搭建方案分为三部分：1、配置dnspod解析记录；2、利用bind9搭建私有dns服务器；3、ddns实现脚本；&lt;/p&gt;

&lt;h2 id=&quot;配置dns供应商的解析记录以dnspod为例&quot;&gt;配置dns供应商的解析记录（以dnspod为例）&lt;/h2&gt;

&lt;p&gt;1、添加A记录，将域名dns.domain.com解析至服务器的ip地址，即将该域名指向dns服务器：&lt;/p&gt;

&lt;p&gt;2、添加NS记录，将webdav.domain.com的解析服务器设定为1中设置的dns服务器&lt;/p&gt;

&lt;p&gt;利用上面的两步即可将域名webdav.domain.com交由自己的dns服务器进行解析。&lt;/p&gt;

&lt;p&gt;对解析记录不了解的可以参考：
&lt;a href=&quot;https://blog.csdn.net/lxf0613050210/article/details/50615297?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163106978516780262515443%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163106978516780262515443&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-50615297.first_rank_v2_pc_rank_v29&amp;amp;utm_term=%E4%B8%BB%E6%9C%BA%E8%AE%B0%E5%BD%95%E7%B1%BB%E5%9E%8B&amp;amp;spm=1018.2226.3001.4187&quot;&gt;域名解析的记录类型：A记录、CNAME…&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;利用bind9搭建私有dns服务器以ubuntu系统为例&quot;&gt;利用bind9搭建私有dns服务器（以ubuntu系统为例）&lt;/h2&gt;

&lt;p&gt;输入以下命令安装bind9：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt install bind9&lt;/code&gt;
bind9的默认路径如下：&lt;/p&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;配置文件&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resolv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 配置解析服务器的地址
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;named&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 主配置文件，自动include下面两个配置文件中的信息(.local/.option)
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;named&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 列出了所有区域数据文件(.zone)的信息
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;etc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;named&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;option&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 定义选项
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;区域数据文件&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 工作路径，用于存放.zone的区域配置文件
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 定义区域域名解析的具体参数
# 文件名命名格式无限定
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bind&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 定义反向解析时的具体参数
# 文件名命名格式无限定
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;etcresolvconf&quot;&gt;/etc/resolv.conf&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;nameserver&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;127.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 设置本地采用的域名解析服务器地址。
# 欲利用nslookup查询bind9设置情况时需要将其设置为127.0.0.1
# 但是当设置为127.0.0.1地址后，本所有dns流量均被其劫持可能会导致无法上网，
# 正确的方式是添加在设置为127.0.0.1后，在添加如下的一条规则
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nameserver&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;8.8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;8.8&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 但是在该文件中配置的信息，在重启systemd-resolved服务后均将失效
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;永久修改的方法如下&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;：&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# 在/etc/network/interfaces文件中添加配置即可
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nameservers&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;8.8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;8.8&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nameservers&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;127.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;关于防止/etc/resolv.conf被失效的方法详情见：
&lt;a href=&quot;https://blog.csdn.net/yuyan_jia/article/details/86301792?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163136889416780366546104%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163136889416780366546104&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-18-86301792.first_rank_v2_pc_rank_v29&amp;amp;utm_term=+resolvconf&amp;amp;spm=1018.2226.3001.4187&quot;&gt;ubuntu解决resolv.conf被重写问题&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;etcbindnamedconf&quot;&gt;/etc/bind/named.conf&lt;/h3&gt;

&lt;p&gt;一般无需配置，默认即可&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// This is the primary configuration file for the BIND DNS server named.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Please read /usr/share/doc/bind9/README.Debian.gz for information on the&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// structure of BIND configuration files in Debian, *BEFORE* you customize&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// this configuration file.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// If you are just adding zones, please do that in /etc/bind/named.conf.local&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/etc/bind/named.conf.options&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/etc/bind/named.conf.local&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/etc/bind/named.conf.default-zones&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;etcbindnamedconflocal&quot;&gt;/etc/bind/named.conf.local&lt;/h3&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Do any local configuration here&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Consider adding the 1918 zones here, if they are not used in your&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// organization&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//include &quot;/etc/bind/zones.rfc1918&quot;;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;//key &quot;ddns&quot; {&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//        algorithm hmac-md5;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//        secret &quot;GAgsKfYTueMc4lawB8qKzg==&quot;;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//};&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;kasumiksm.com&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;master&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/var/cache/bind/kasumiksm.com.zone&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 添加一个正向解析的区域，当需要查询的域名的根域名为kasumiksm.com时&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 均会查询该区域。即不可将携带其他根域名的域名放在该区域。&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 如需让该区域负责所有.com结尾的域名时，将&quot;kasumiksm.com&quot;改为&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// &quot;com&quot;即可（未测试）&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;zone&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;117.1.in-addr.arpa&quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;master&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/var/cache/bind/ip.zone&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 添加一个反向解析的区域，并非必须的区域，当需要查询的ip的头几位为1.117时&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 将进入该区域查询，勿将其他开头的ip地址放入该区域(注意这里的ip需反向写)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// 如需将该区域设置为反向解析所有的ip，则将&quot;117.1.in-addr.arpa&quot;改为&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// &quot;in-addr.arpa&quot;即可（已测试）&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;etcbindnamedconfoption&quot;&gt;/etc/bind/named.conf.option&lt;/h3&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;directory&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/var/cache/bind&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;c1&quot;&gt;//设置工作路径&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// If there is a firewall between you and nameservers you want&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// to talk to, you may need to fix the firewall to allow multiple&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// ports to talk.  See http://www.kb.cert.org/vuls/id/800113&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// If your ISP provided one or more IP addresses for stable&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// nameservers, you probably want to use them as forwarders.&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// Uncomment the following block, and insert the addresses replacing&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// the all-0's placeholder.&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;// forwarders {&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//      0.0.0.0;&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// };&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;//========================================================================&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// If BIND logs error messages about the root key being expired,&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// you will need to update your keys.  See https://www.isc.org/bind-keys&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;//========================================================================&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;dnssec&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;validation&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;auto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v6&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;any&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//开启listen-on-v6就会默认也监听ipv4。&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//listen-on { 5.6.7.8; };会默认监听5.6.7.8:53，即在5.6.7.8监听53端口&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//listen-on port 1234 { 127.0.0.1; };会监听127.0.0.1:1234&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;allow&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;any&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;};&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//定义可以进行dns查询的主机,如：allow-query {127.0.0.1;};只能通过本机查询&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//allow-query也能在zone语句中设定，这样全局options中的allow-query选项&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//在这里就不起作用了。&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;auth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nxdomain&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;no&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;c1&quot;&gt;//默认即可&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;更进一步的设置参考：
&lt;a href=&quot;https://blog.csdn.net/weixin_40470303/article/details/80642190?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163116802616780265424016%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163116802616780265424016&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-4-80642190.first_rank_v2_pc_rank_v29&amp;amp;utm_term=%E8%87%AA%E5%B7%B1%E7%9A%84dns%E8%A7%A3%E6%9E%90%E6%9C%8D%E5%8A%A1%E5%99%A8&amp;amp;spm=1018.2226.3001.4187&quot;&gt;DNS域名解析服务器&lt;/a&gt;
&lt;a href=&quot;https://blog.csdn.net/weixin_34310369/article/details/92217300?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163137045816780255289494%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163137045816780255289494&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-2-92217300.first_rank_v2_pc_rank_v29&amp;amp;utm_term=auth-nxdomain&amp;amp;spm=1018.2226.3001.4187&quot;&gt;BIND配置文件详解（二）&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;varcachebindkasumiksmcomzone&quot;&gt;/var/cache/bind/kasumiksm.com.zone&lt;/h3&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TTL&lt;/span&gt;	&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//ttl 10秒	//dns服务器的域名	//管理员的邮箱，为了防止歧义将@改为.&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;SOA&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;      &lt;span class=&quot;mi&quot;&gt;1412251241&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;qq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.(&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serial&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//序列号&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;refresh&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;retry&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expire&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;negative&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ttl&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;//域名	interntet 记录类型 正向解析的结果	&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;NS&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;       &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;247&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;180&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;       &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;abc&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;A&lt;/span&gt;       &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;当域名写成&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns&lt;/code&gt;和&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns.&lt;/code&gt;分别代表dns.kasumiksm.com.以及dns.
即如果没有点则会自动在后面补充区域的域名&lt;/p&gt;

&lt;h3 id=&quot;varcachebindipzone&quot;&gt;/var/cache/bind/ip.zone&lt;/h3&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TTL&lt;/span&gt;    &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;SOA&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;      &lt;span class=&quot;mi&quot;&gt;1412251241&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;qq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.(&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;      &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serial&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;refresh&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;   &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;retry&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expire&lt;/span&gt;
                                &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;M&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;negative&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ttl&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;@&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;NS&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;180&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;247&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;PTR&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;dns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;PTR&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;webdav&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;117&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;       &lt;span class=&quot;n&quot;&gt;IN&lt;/span&gt;      &lt;span class=&quot;n&quot;&gt;PTR&lt;/span&gt;     &lt;span class=&quot;n&quot;&gt;abc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kasumiksm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;与域名的设置类似，但是要注意将ip反向书写&lt;/p&gt;

&lt;h3 id=&quot;检查写好的配置文件格式是否合规&quot;&gt;检查写好的配置文件格式是否合规&lt;/h3&gt;

&lt;p&gt;利用&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;named-checkconf&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;named-checkzone&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;分别对配置文件及区域文件进行格式的检查。&lt;/p&gt;

&lt;p&gt;参考链接：&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/CongxCX/article/details/105844335?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163117630016780261948273%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163117630016780261948273&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-9-105844335.first_rank_v2_pc_rank_v29&amp;amp;utm_term=bind9+api&amp;amp;spm=1018.2226.3001.4187&quot;&gt;基于Linux(CentOS/Ubuntu)使用Bind9自建私有权威DNS&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;bugshooting&quot;&gt;bugshooting&lt;/h3&gt;

&lt;p&gt;因为之前将.zone文件直接放在/etc/bind/目录下，导致在利用nsupdate修改时出错（就算如何修改文件的权限，也会提示无权限创建.jnl文件的错误）遇到这个问题是因为ubuntu的Apparmor机制。可以在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/log/kern.log&lt;/code&gt;看到错误日志。&lt;/p&gt;

&lt;p&gt;想要去除该bug的方法有二：
方法一、运行指令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo aa-complain /path/to/bin&lt;/code&gt;。其中&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/path/to/bin&lt;/code&gt;代表可执行文件的路径。该信息会在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/log/kern.log&lt;/code&gt;中体现。
该指令可开启complain模式，使得Apparmor不再直接拦截应用的行为，但是仍会在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/log/kern.log&lt;/code&gt;产生complain记录。
方法二、在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apparmor.d&lt;/code&gt;修改相关程序的配置文件如对于bind9，其相关的配置文件为：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apparmor.d/usr.sbin.named&lt;/code&gt;。通过指令
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dpkg -S /etc/apparmor.d/usr.sbin.named&lt;/code&gt;
可以查询该配置文件对应的程序名称。例如：bind9&lt;/p&gt;

&lt;p&gt;相关参考链接：
&lt;a href=&quot;https://wiki.ubuntu.com/DebuggingApparmor&quot;&gt;DebuggingApparmor&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;参考链接&quot;&gt;参考链接：&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/CongxCX/article/details/105844335?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163117630016780261948273%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163117630016780261948273&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-9-105844335.first_rank_v2_pc_rank_v29&amp;amp;utm_term=bind9+api&amp;amp;spm=1018.2226.3001.4187&quot;&gt;基于Linux(CentOS/Ubuntu)使用Bind9自建私有权威DNS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/weixin_40470303/article/details/80642190?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163116802616780265424016%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163116802616780265424016&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-4-80642190.first_rank_v2_pc_rank_v29&amp;amp;utm_term=%E8%87%AA%E5%B7%B1%E7%9A%84dns%E8%A7%A3%E6%9E%90%E6%9C%8D%E5%8A%A1%E5%99%A8&amp;amp;spm=1018.2226.3001.4187&quot;&gt;DNS域名解析服务器&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/weixin_34310369/article/details/92217300?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163137045816780255289494%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163137045816780255289494&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-2-92217300.first_rank_v2_pc_rank_v29&amp;amp;utm_term=auth-nxdomain&amp;amp;spm=1018.2226.3001.4187&quot;&gt;BIND配置文件详解（二）&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.cnblogs.com/doherasyang/p/14464999.html#6-dns-server%E7%9A%84%E5%AE%89%E5%85%A8%E6%80%A7%E9%85%8D%E7%BD%AE&quot;&gt;ISC BIND9 - 最详细、最认真的从零开始的 BIND 9 - DNS服务搭建及其原理讲解&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jangrui.com/linux/service/bind/#bind_1&quot;&gt;Bind 域名解析服务&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;ddns实现脚本&quot;&gt;ddns实现脚本&lt;/h2&gt;

&lt;h3 id=&quot;ddns脚本预备知识&quot;&gt;ddns脚本预备知识&lt;/h3&gt;

&lt;h4 id=&quot;rndc工具&quot;&gt;rndc工具&lt;/h4&gt;

&lt;p&gt;运行命令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo rndc reload&lt;/code&gt;即可重新加载bind9的所有配置文件及区域数据文件(.zone)，进行配置及ip地址的更新。&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo rndc reload kasumiksm.com.zone&lt;/code&gt;可以加载单个区域文件进行更新。当运行指令后出现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rndc: 'reload' failed: dynamic zone&lt;/code&gt;的提示。则需要修改named.conf.local文件。参见：&lt;a href=&quot;https://blog.csdn.net/ljflm/article/details/88926248?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163126532516780271560316%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163126532516780271560316&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-1-88926248.first_rank_v2_pc_rank_v29&amp;amp;utm_term=rndc%3A+%27reload%27+failed%3A+dynamic+zone&amp;amp;spm=1018.2226.3001.4187&quot;&gt;利用rndc对单个zone进行reload的时候提示rndc: ‘reload’ failed: dynamic zone&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;参考链接：
&lt;a href=&quot;https://blog.51cto.com/leeyan/1695385&quot;&gt;bind详解，主从DNS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/ljflm/article/details/88926248?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163126532516780271560316%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163126532516780271560316&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-1-88926248.first_rank_v2_pc_rank_v29&amp;amp;utm_term=rndc%3A+%27reload%27+failed%3A+dynamic+zone&amp;amp;spm=1018.2226.3001.4187&quot;&gt;利用rndc对单个zone进行reload的时候提示rndc: ‘reload’ failed: dynamic zone&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;ddns功能实现方式&quot;&gt;ddns功能实现方式&lt;/h4&gt;

&lt;h5 id=&quot;利用python脚本结合bash实现登录ssh主机修改zone文件&quot;&gt;利用python脚本结合bash，实现登录ssh主机修改.zone文件&lt;/h5&gt;

&lt;p&gt;本文采用的即是该方法，需要考虑以下问题：
1、利用python3中的paramiko模块可以通过ssh登录服务器（支持密码登录以及密钥登陆）。使用方法：
&lt;a href=&quot;https://blog.csdn.net/weixin_39643613/article/details/110068872?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127152516780271511575%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163127152516780271511575&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-20-110068872.first_rank_v2_pc_rank_v29&amp;amp;utm_term=python+ssh+%E8%BF%9E%E6%8E%A5%E8%BF%9C%E7%A8%8B%E6%9C%8D%E5%8A%A1%E5%99%A8&amp;amp;spm=1018.2226.3001.4187&quot;&gt;python通过ssh连接服务器，执行命令&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/diaoyou7779/article/details/101536866?ops_request_misc=&amp;amp;request_id=&amp;amp;biz_id=102&amp;amp;utm_term=python%20%E7%99%BB%E5%BD%95%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-6-101536866.first_rank_v2_pc_rank_v29&amp;amp;spm=1018.2226.3001.4187&quot;&gt;python ssh 连接远程服务器，修改文本内容，调用脚本&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/rongDang/article/details/98181689?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127382616780269838537%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163127382616780269838537&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-98181689.first_rank_v2_pc_rank_v29&amp;amp;utm_term=paramiko+%E5%AF%86%E9%92%A5&amp;amp;spm=1018.2226.3001.4187&quot;&gt;paramiko使用秘钥连接&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2、对服务器的ubuntu系统进行设置，生成密钥，并使其支持密钥登陆。参考链接：
&lt;a href=&quot;https://blog.csdn.net/weixin_42256332/article/details/85595630?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127475116780262589778%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163127475116780262589778&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-2-85595630.first_rank_v2_pc_rank_v29&amp;amp;utm_term=ubuntu+%E7%94%A8%E5%AF%86%E9%92%A5%E7%99%BB%E9%99%86&amp;amp;spm=1018.2226.3001.4187&quot;&gt;UBUNTU设置SSH通过密钥登陆&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/cunchi4221/article/details/107477470?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127417016780366512068%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163127417016780366512068&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-6-107477470.first_rank_v2_pc_rank_v29&amp;amp;utm_term=ubuntu+%E7%94%9F%E6%88%90%E5%AF%86%E9%92%A5&amp;amp;spm=1018.2226.3001.4187&quot;&gt;ubuntu ssh密钥_生成SSH密钥以在Ubuntu中进行无密码登录&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3、为避免执行sudo后，会出现的密码验证。需要对服务器进行如下设置：
&lt;a href=&quot;https://blog.csdn.net/weixin_39571864/article/details/83743895?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127575016780265466521%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163127575016780265466521&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-2-83743895.first_rank_v2_pc_rank_v29&amp;amp;utm_term=ubuntu+sudo+%E6%97%A0%E9%9C%80%E8%BE%93%E5%85%A5%E5%AF%86%E7%A0%81&amp;amp;spm=1018.2226.3001.4187&quot;&gt;ubuntu sudo不需要输入密码的方法&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4、为了实现ddns，必须先获得内网主机的公网ip地址。实现代码如下：
&lt;a href=&quot;https://blog.csdn.net/whatday/article/details/109332906?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163128798716780262570954%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&amp;amp;request_id=163128798716780262570954&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v29_ecpm-2-109332906.first_rank_v2_pc_rank_v29&amp;amp;utm_term=python%E8%8E%B7%E5%8F%96%E5%85%AC%E7%BD%91ip%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F&amp;amp;spm=1018.2226.3001.4187&quot;&gt;python 获取公网 外网 ip 几种方式&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5、通过bash语言中的sed指令对服务器上的.zone文件进行修改。
需要理解的指令有：&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sed -i '$ahello'  1.txt  # 在最后一行添加hello&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sed -i '/123/d'   1.txt   # 删除以123开头的行&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;更多参考链接：&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/p15097962069/article/details/103983313?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127925116780261989484%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163127925116780261989484&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-103983313.first_rank_v2_pc_rank_v29&amp;amp;utm_term=bash+%E5%88%A0%E9%99%A4%E4%B8%80%E8%A1%8C&amp;amp;spm=1018.2226.3001.4187&quot;&gt;如何使用bash / sed脚本删除文本文件的第一行？&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/lilyssh/article/details/108581758?ops_request_misc=&amp;amp;request_id=&amp;amp;biz_id=102&amp;amp;utm_term=bash%20%E5%88%A0%E9%99%A4%E4%B8%80%E8%A1%8C&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-6-108581758.first_rank_v2_pc_rank_v29&amp;amp;spm=1018.2226.3001.4187&quot;&gt;Linux shell 用sed删除第一行、最后一行或增加删除某行&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/angelahhj/article/details/53260832?ops_request_misc=&amp;amp;request_id=&amp;amp;biz_id=102&amp;amp;utm_term=sed%E6%B7%BB%E5%8A%A0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-6-53260832.first_rank_v2_pc_rank_v29&amp;amp;spm=1018.2226.3001.4187&quot;&gt;sed命令（删除与追加）&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://blog.csdn.net/wdz306ling/article/details/80087889?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163127961216780366522941%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163127961216780366522941&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~top_positive~default-1-80087889.first_rank_v2_pc_rank_v29&amp;amp;utm_term=sed%E5%91%BD%E4%BB%A4&amp;amp;spm=1018.2226.3001.4187&quot;&gt;shell脚本–sed的用法&lt;/a&gt;&lt;/p&gt;

&lt;h5 id=&quot;利用nsupdate工具&quot;&gt;利用nsupdate工具&lt;/h5&gt;

&lt;p&gt;该方法本身存在一些问题，并不推荐。这里只做参考：
&lt;a href=&quot;https://www.jianshu.com/p/0a47b6c3d5e0&quot;&gt;bind9 实现动态解析域名&lt;/a&gt;
&lt;a href=&quot;https://www.haiyun.me/archives/bind-ddns.html&quot;&gt;使用BIND配置动态DDNS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;在github上有利用该方法实现ddns的例子，供参考：
&lt;a href=&quot;https://github.com/andreasscherbaum/bind-dynamic-dns-update&quot;&gt;andreasscherbaum/bind-dynamic-dns-update&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;实现脚本&quot;&gt;实现脚本&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;paramiko&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;urllib.request&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;json&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;LinuxOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;private_key_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;&quot;&quot;&quot;
        :param demain: 服务器域名或地址均可
        :param port: ssh 连接的端口
        :param username: 服务器用户名
        :param private_key_path: 本地密钥路径
        :param timeout: 连接超时时间
        &quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;private_key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;paramiko&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RSAKey&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_private_key_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;private_key_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;paramiko&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SSHClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_missing_host_key_policy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;paramiko&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AutoAddPolicy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pkey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;private_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'{0}：连接成功'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Exception&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'{0}：连接失败'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;e&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;&quot;&quot;&quot;
        执行代码
        :param order: 命令
        :return:
        &quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;stdin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;exec_command&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stderr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;close_ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;&quot;&quot;&quot;关闭ssh连接&quot;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'关闭ssh连接'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__name__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'__main__'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'dns.kasumiksm.com'&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# dns服务器域名或ip地址均可
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;port&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'22'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;usr&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'ubuntu'&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;private_key_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'cvm_shanghai3.pem'&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 本地密匙
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;ddns_ip&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;load&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;urlopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'https://api.ipify.org/?format=json'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'ip'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# 获取ddns的公网ip
&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# 第一行为删除以webdav开始的行，第二行为添加webdav的解析记录，第三行为更改区域文件的权限，第四行为重载区域文件及配置文件，更新ip
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;order&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;sudo sed -i '/^webdav/d' /var/cache/bind/kasumiksm.com.zone&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt; \
            &lt;span class=&quot;s&quot;&gt;&quot;sudo sed -i '$awebdav&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;IN&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\t&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ddns_ip&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;' /var/cache/bind/kasumiksm.com.zone&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt; \
            &lt;span class=&quot;s&quot;&gt;&quot;sudo chown bind:bind /var/cache/bind/kasumiksm.com.zone&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt; \
            &lt;span class=&quot;s&quot;&gt;&quot;sudo rndc reload&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;L&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LinuxOrder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usr&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;private_key_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;L&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;order&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;L&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;close_ssh&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;dns测试工具&quot;&gt;dns测试工具&lt;/h3&gt;

&lt;p&gt;正向解析：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nslookup webdav.kasumiksm.com&lt;/code&gt;
得出如下结果即为设置成功&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Server:		127.0.0.1
Address:	127.0.0.1#53

Name:	webdav.kasumiksm.com
Address: 2.2.2.2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;反向解析：
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nslookup 1.117.247.180&lt;/code&gt;
得出如下结果即为设置成功&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;180.247.117.1.in-addr.arpa	name = dns.kasumiksm.com.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Tue, 15 Dec 2020 00:00:00 +0800</pubDate>
        <link>/2020-12/%E5%87%A0%E7%A7%8D%E6%90%AD%E5%BB%BA%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E7%8E%AF%E5%A2%83%E7%9A%84%E6%96%B9%E6%A1%88%E5%8F%8A%E5%AE%9E%E7%8E%B0-%E4%BA%8C-bind9%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89dns%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%B9%B6%E5%AE%9E%E7%8E%B0ddns.html</link>
        <guid isPermaLink="true">/2020-12/%E5%87%A0%E7%A7%8D%E6%90%AD%E5%BB%BA%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E7%8E%AF%E5%A2%83%E7%9A%84%E6%96%B9%E6%A1%88%E5%8F%8A%E5%AE%9E%E7%8E%B0-%E4%BA%8C-bind9%E6%90%AD%E5%BB%BA%E7%A7%81%E6%9C%89dns%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%B9%B6%E5%AE%9E%E7%8E%B0ddns.html</guid>
        
        
        <category>intranet penetration</category>
        
      </item>
    
      <item>
        <title>几种搭建内网穿透环境的方案及实现（一）：各种方案的介绍与比较</title>
        <description>&lt;h2 id=&quot;内网穿透的介绍&quot;&gt;内网穿透的介绍&lt;/h2&gt;

&lt;p&gt;内网穿透的主要任务是，为处于内网的主机取得与处于其他内网的主机通信的链路。众所周知，因为ipv4的ip资源紧缺，使得内网的架构越发普及。而处于内网的主机往往是没有独立公网ip的，也就是说，处于内网的主机在公网上的位置并不是唯一的，它与其它同处一个内网的主机公用一个公网ip地址。这样就产生了，如何才能使得处于不同内网的主机进行通信的问题。目前的内网穿透方案主要有下面两个流派:1、借助内网穿透软件实现；2、通过ddns实现。&lt;/p&gt;

&lt;h2 id=&quot;利用内网穿透工具实现穿透&quot;&gt;利用内网穿透工具实现穿透&lt;/h2&gt;

&lt;h3 id=&quot;zerotier&quot;&gt;zerotier&lt;/h3&gt;

&lt;p&gt;常用的内网穿透软件有zerotier和frp，先说一说zerotier这款软件的实现思路。它主要通过在多台主机上创建虚拟网卡，通过该网卡，在公网上实现一个虚拟的局域网。下图是对zerotier技术进行的一个图示。&lt;/p&gt;

&lt;p&gt;在默认情况下，zerotier会提供官方的主机作为这个虚拟局域网的网关，来进行流量的引导。但是因为它的主机处于境外，故对国内的用户来说不是太友好。另外zerotier也允许用户自己搭建moon，也就是利用客户自己的主机作为虚拟局域网的网关，不过在一定条件下，自建的moon应该还是需要和官方的主机进行通信的。这个方案的好处在于，这样建立的内网穿透方式，各个主机之间的的流量阈值，由其各个内网本身的带宽决定。这与frp的方案不同，在frp的方案中，带宽受到制约的环节更多。但是这个方案本身也有一些问题，第一个问题是，官方服务器处于境外带来的网络连接不稳定的问题，另外一个问题是，当内网的架构非常复杂时，zerotier提供的内网穿透将可能失效（任何处于内网的设备都会受到该影响）。&lt;/p&gt;

&lt;h3 id=&quot;frp&quot;&gt;frp&lt;/h3&gt;

&lt;p&gt;而frp采取的则是与zerotier完全不同的方案，frp通过将内网主机的固定端口映射到具有公网ip主机的固定端口上，以此来帮助内网的设备，使其能够在公网上拥有一个固定的位置。下图是frp技术的图示。&lt;/p&gt;

&lt;p&gt;这种方案的缺点有二：第一个缺点、必须拥有一台具有公网ip的主机，而国内的vps由于高昂的带宽费用，除非是首单，否则基本上是1000/年起步的，而国外的vps相对便宜，可以做到200-300/年。所以，光是这一条就可以筛选掉大部分的人了。第二个缺点是，因为frp是采用将内网主机映射到公网主机的端口上，故其通信的带宽将同时受到内网带宽以及服务器（具有公网ip的主机）带宽的限制。而国内的服务器带宽也是贵的吓人（都是被各个直播平台炒起来的，直播平台都是消耗带宽的大户)，5M的带宽直接就比服务器本身还贵了。&lt;/p&gt;

&lt;h2 id=&quot;利用ddns技术实现穿透&quot;&gt;利用ddns技术实现穿透&lt;/h2&gt;

&lt;p&gt;除了上面提到的内网穿透工具的方案外，还可以通过ddns来实现内网穿透。要实现ddns的必须要先购买一个域名，当然，国外的域名供应商也提供一些免费的域名供使用，当然付费的域名也不贵，从几十到几百每年不等。&lt;/p&gt;

&lt;h3 id=&quot;调用dns供应商api的方案&quot;&gt;调用DNS供应商API的方案&lt;/h3&gt;

&lt;p&gt;实现ddns的方案有很多，下图是一般ddns的实现方式：&lt;/p&gt;

&lt;p&gt;主要分为两类：一、利用域名解析供应商提供的api，实现ddns服务。每隔一段时间通过脚本获取内网主机的公网ip，并利用api修改域名对应的ip地址。使得始终可以通过设定好的域名，跟踪内网主机对应的公网ip。github上有一个项目&lt;a href=&quot;https://github.com/NewFuture/DDNS&quot;&gt;NewFuture/DDNS&lt;/a&gt;，它做的很好，支持腾讯云、阿里云、cloudflare等多个平台。这类方案的最大缺点在于免费用户的ttl往往很大，以腾讯云举例，其ttl达到了600秒。也就是在修改dns记录后，一般需要过10分钟后才能生效。如果在内网上搭建私人网盘的话，在这段时间内是无法访问这个网盘的。&lt;/p&gt;

&lt;h3 id=&quot;自建dns服务器的方案&quot;&gt;自建DNS服务器的方案&lt;/h3&gt;

&lt;p&gt;另外一类实现ddns的方式是，在自己的服务器上搭建域名解析服务器（如：bind），利用该服务器为域名提供ip地址的解析，这样就不必受限于域名解析供应商设定的ttl等参数。这种方案的缺点是需要购买一台服务器。&lt;/p&gt;

&lt;p&gt;接下来将对各个方案的搭建方式分别做详细的介绍。&lt;/p&gt;
</description>
        <pubDate>Fri, 23 Oct 2020 00:00:00 +0800</pubDate>
        <link>/2020-10/%E5%87%A0%E7%A7%8D%E6%90%AD%E5%BB%BA%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E7%8E%AF%E5%A2%83%E7%9A%84%E6%96%B9%E6%A1%88%E5%8F%8A%E5%AE%9E%E7%8E%B0-%E4%B8%80-%E5%90%84%E7%A7%8D%E6%96%B9%E6%A1%88%E7%9A%84%E4%BB%8B%E7%BB%8D%E4%B8%8E%E6%AF%94%E8%BE%83.html</link>
        <guid isPermaLink="true">/2020-10/%E5%87%A0%E7%A7%8D%E6%90%AD%E5%BB%BA%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E7%8E%AF%E5%A2%83%E7%9A%84%E6%96%B9%E6%A1%88%E5%8F%8A%E5%AE%9E%E7%8E%B0-%E4%B8%80-%E5%90%84%E7%A7%8D%E6%96%B9%E6%A1%88%E7%9A%84%E4%BB%8B%E7%BB%8D%E4%B8%8E%E6%AF%94%E8%BE%83.html</guid>
        
        
        <category>intranet penetration</category>
        
      </item>
    
      <item>
        <title>利用frp实现内网穿透</title>
        <description>&lt;h2 id=&quot;前置步骤&quot;&gt;前置步骤：&lt;/h2&gt;

&lt;p&gt;1、在&lt;a href=&quot;https://github.com/fatedier/frp&quot;&gt;仓库&lt;/a&gt;复制frp的安装包&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frp_0.37.1_linux_amd64.tar.gz&lt;/code&gt;（适合x86架构）&lt;/p&gt;

&lt;p&gt;2、wget + frp安装包链接&lt;/p&gt;

&lt;p&gt;3、通过指令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar -zxvf&lt;/code&gt;解压&lt;/p&gt;

&lt;h2 id=&quot;服务器配置步骤&quot;&gt;服务器配置步骤：&lt;/h2&gt;

&lt;p&gt;1、对修改服务器配置文件&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano frp/frps.ini&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2、添加&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;token = password&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3、试运行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./frps -c ./frps.ini&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4、添加frps系统服务&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/systemd/system/frps.service&lt;/code&gt;(这里的文件名决定了以后通过service或systemctl启动时输入的服务名)，并做如下修改&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=frps service
After=syslog.target network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/home/ubuntu/frp/frps -c /home/ubuntu/frp/frps.ini

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;bug shotting: 
如果服务设置自启后出现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dial tcp xxx.xxx.xxx.xxx:7000: connect: network is unreachable&lt;/code&gt;的错误
解决方案：修改为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;After=multi-user.target&lt;/code&gt;即，使得frp服务最后启动。&lt;a href=&quot;https://blog.csdn.net/Lin3P/article/details/82941572&quot;&gt;参考链接&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5、利用服务启动frps：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl start frps&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;bug shotting:
systemctl start xxx时出现报错：Failed to start XXX.service: Unit not found.
解决方案：systemctl daemon-reload：重新加载某个服务的配置文件。&lt;a href=&quot;https://blog.csdn.net/CN_TangZheng/article/details/111867712?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163030363216780357270669%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163030363216780357270669&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-2-111867712.first_rank_v2_pc_rank_v29&amp;amp;utm_term=Failed+to+start+frpc.service%3A+Unit+frpc.service+not+found.&amp;amp;spm=1018.2226.3001.4187&quot;&gt;参考链接&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;6、设置frps自启动：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl enable frps&lt;/code&gt;&lt;/p&gt;

&lt;h2 id=&quot;客户端配置步骤&quot;&gt;客户端配置步骤：&lt;/h2&gt;

&lt;p&gt;1、对修改服务器配置文件&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano frp/frpc.ini&lt;/code&gt;，做如下修改&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[common]
server_addr = 81.68.149.215  # 服务器ip
server_port = 7000  # 服务器端口
token = UlXjYoe1JLl55gvRXDIlwqLoc4kvQV

[ssh]  # 别名，不可重名
type = tcp
local_ip = 127.0.0.1  # 相对本机的地址
local_port = 6000  # 本地的地址
remote_port = 6000  # 映射到服务器上的地址
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2、试运行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./frpc -c ./frpc.ini&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3、添加frps系统服务&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/systemd/system/frpc.service&lt;/code&gt;(这里的文件名决定了以后通过service或systemctl启动时输入的服务名)，并做如下修改&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=frpc service
After=syslog.target network.target
Wants=network.target

[Service]
Type=simple
ExecStart=/home/ksm/frp/frpc -c /home/ksm/frp/frpc.ini

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;bug shotting: 
如果服务设置自启后出现&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dial tcp xxx.xxx.xxx.xxx:7000: connect: network is unreachable&lt;/code&gt;的错误
解决方案：修改为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;After=multi-user.target&lt;/code&gt;即，使得frp服务最后启动。&lt;a href=&quot;https://blog.csdn.net/Lin3P/article/details/82941572&quot;&gt;参考链接&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4、利用服务启动frps：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl start frpc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;5、设置frps自启动：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl enable frpc&lt;/code&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 12 Sep 2020 00:00:00 +0800</pubDate>
        <link>/2020-09/%E5%88%A9%E7%94%A8frp%E5%AE%9E%E7%8E%B0%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F.html</link>
        <guid isPermaLink="true">/2020-09/%E5%88%A9%E7%94%A8frp%E5%AE%9E%E7%8E%B0%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F.html</guid>
        
        
        <category>intranet penetration</category>
        
      </item>
    
      <item>
        <title>利用Docusaurus搭建个人网站</title>
        <description>&lt;h2 id=&quot;nodejs包含npmnpx的安装&quot;&gt;node.js(包含npm、npx)的安装&lt;/h2&gt;

&lt;p&gt;不推荐使用&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt install node.js&lt;/code&gt;的方式安装，这种方式会安装老版本的node。
1、到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https://nodejs.org/en/download/&lt;/code&gt;找到相应操作系统的下载链接&lt;/p&gt;

&lt;p&gt;2、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget https://nodejs.org/dist/v14.17.6/node-v14.17.6-linux-x64.tar.xz&lt;/code&gt;下载node.js&lt;/p&gt;

&lt;p&gt;3、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar -xvf node-v14.17.6-linux-x64.tar.xz&lt;/code&gt;解压，解压后得到&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/node-v14.17.6-linux-x64&lt;/code&gt;的目录&lt;/p&gt;

&lt;p&gt;4、&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd /node-v14.17.6-linux-x64/bin&lt;/code&gt;找到可执行文件所在路径。注意将文件夹名改为自己的，下同。&lt;/p&gt;

&lt;p&gt;5、将可执行文件所在路径添加至PATH变量：在&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt;文件中添加&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;export PATH=$PATH:/home/ksm/node-v14.17.6-linux-x64/bin&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;6、分别为node、npm、npx在/usr/bin下建立软链接（这样才可以用sudo npm或sudo npx来赋予管理员权限）：&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo ln -s /home/data/node-v14.17.6-linux-x64/bin/node /usr/bin/node
sudo ln -s /home/data/node-v14.17.6-linux-x64/bin/npm /usr/bin/npm
sudo ln -s /home/data/node-v14.17.6-linux-x64/bin/pm2 /usr/bin/npx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;参考链接：&lt;a href=&quot;https://blog.csdn.net/qq_24601199/article/details/103806150?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163055381216780269883352%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&amp;amp;request_id=163055381216780269883352&amp;amp;biz_id=0&amp;amp;utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduend~default-1-103806150.first_rank_v2_pc_rank_v29&amp;amp;utm_term=sudo+npm%E6%89%BE%E4%B8%8D%E5%88%B0%E5%91%BD%E4%BB%A4&amp;amp;spm=1018.2226.3001.4187&quot;&gt;sudo运行npm/node出现找不到命令情况&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;docusaurus搭建&quot;&gt;Docusaurus搭建&lt;/h2&gt;
&lt;p&gt;1、任意切换到一个目录，如&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/&lt;/code&gt;。&lt;/p&gt;

&lt;p&gt;2、运行指令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo npx @docusaurus/init@latest init [name] [template]&lt;/code&gt;该指令将在当前目录下创建name文件夹，并自动下载template模板。&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;如：&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo npx @docusaurus/init@latest init my-website classic&lt;/code&gt;将新建my-website文件夹&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;2.1、测试Docusaurus搭建的效果：首先进入项目的文件夹&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd my-website&lt;/code&gt;。然后运行指令&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo npm run start&lt;/code&gt;进行试运行，该指令会将网站架设在本地计算机的3000端口上。此时只需要在浏览器输入&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://localhost:3000&lt;/code&gt;即可会网站进行访问。&lt;/p&gt;

&lt;p&gt;3、生成静态网站。Docusaurus 是一个的静态网站生成器，首先需要进入项目目录&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cd my-website&lt;/code&gt;。然后运行&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo npm run build&lt;/code&gt;，编译生成静态网站（会在my-website目录下生成build目录，该目录下包含了网站的所有信息）。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;生成静态网页后，最好修改其权限&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo chmod 777 build&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;4、将生成的build文件夹移动到apache2指定的网站根目录，即可通过浏览器访问网站。&lt;/p&gt;

&lt;p&gt;参考文献：
&lt;a href=&quot;https://www.docusaurus.cn/docs/installation&quot;&gt;Docusaurus 中文网&lt;/a&gt;
&lt;a href=&quot;https://github.com/facebook/docusaurus&quot;&gt;官方github仓库&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;将模板修改为博客网站&quot;&gt;将模板修改为博客网站&lt;/h2&gt;
&lt;h3 id=&quot;docusaurusconfigjs&quot;&gt;docusaurus.config.js&lt;/h3&gt;
&lt;p&gt;1、将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{to: '/blog', label: blog', position: 'left'}&lt;/code&gt;,修改为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{to: '/', label: '博客', position: 'left'},&lt;/code&gt;
2、将&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
	type: 'doc',
	docId: 'intro',
	position: 'left',
	label: 'doc',
 },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;修改为&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
	type: 'doc',
	docId: 'intro',
	position: 'left',
	label: '技术文档',
 },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3、将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;presets:&lt;/code&gt; 下的&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;blog:&lt;/code&gt;修改为&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;blog: {
	path: &quot;./blog&quot;,
	routeBasePath: &quot;/&quot;,
	showReadingTime: true,
	// Please change this to your repo.
	editUrl:'https://github.com/facebook/docusaurus/edit/main/website/blog/',
},
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;indexjs&quot;&gt;index.js&lt;/h3&gt;
&lt;p&gt;将&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/index.js&lt;/code&gt;的文件名改为&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/pages/index.js.bak&lt;/code&gt;这样才能实现更换主页。&lt;/p&gt;
</description>
        <pubDate>Tue, 21 Jul 2020 00:00:00 +0800</pubDate>
        <link>/2020-07/%E5%88%A9%E7%94%A8Docusaurus%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E7%BD%91%E7%AB%99.html</link>
        <guid isPermaLink="true">/2020-07/%E5%88%A9%E7%94%A8Docusaurus%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E7%BD%91%E7%AB%99.html</guid>
        
        
        <category>Docusaurus</category>
        
      </item>
    
  </channel>
</rss>