<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>wallleap</title>
  
  <subtitle>Luwang&#39;s Blog</subtitle>
  <link href="/atom.xml" rel="self"/>
  
  <link href="https://sakura.wallleap.cn/"/>
  <updated>2020-02-10T04:43:41.421Z</updated>
  <id>https://sakura.wallleap.cn/</id>
  
  <author>
    <name>Luwang</name>
    
  </author>
  
  <generator uri="http://hexo.io/">Hexo</generator>
  
  <entry>
    <title>都2020了，带你开发hexo主题</title>
    <link href="https://sakura.wallleap.cn/2020/02/04/hexotheme/"/>
    <id>https://sakura.wallleap.cn/2020/02/04/hexotheme/</id>
    <published>2020-02-04T14:16:01.000Z</published>
    <updated>2020-02-10T04:43:41.421Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="都2020了，带你开发hexo主题"><a href="#都2020了，带你开发hexo主题" class="headerlink" title="都2020了，带你开发hexo主题"></a>都2020了，带你开发hexo主题</h1><h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>本系列文章是<a href="https://www.hojun.cn/" target="_blank" rel="noopener">博主hojun</a>日常业余折腾HEXO所总结的经验结果，不一定是最佳实践。了解更多请关注<a href="https://hexo.io/" target="_blank" rel="noopener">HEXO官方网站</a>。关于HEXO主题已经折腾过好多，当然拆腾的都是比较有条理的。<br>有关<a href="https://github.com/honjun/hexo-theme-sakura" target="_blank" rel="noopener">HEXO主题Sakura</a>已经是去年（前年）的事了，第一次提交：honjun committed on 20 Dec 2018。偶尔怀旧下23333~，之前<a href="https://www.bilibili.com/video/av43856893" target="_blank" rel="noopener">关于Sakura主题开发也录了大部分的视频教程</a>，不过估计大部分人没有看，毕竟直接拿来用更香。这次准备出文章教程，顺带练习下我那半吊子的五笔打字。</p><h2 id="准备工作"><a href="#准备工作" class="headerlink" title="准备工作"></a>准备工作</h2><p>回归到正文，先总结下该教程的计划，首先html页面不准备写，去html5up上找个模版，众所周知（不知道的现在也知道了）这个网站已经出了好几个HEXO博客，包括Phantom、Massively、strata、simplyspoke、Editorial(还没做完，看完教程的可以用这个模版练练手，给它PR完整)。<br>最后，选定story就刚刚决定的。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66Om7cna03iaBqicXeIzmWPOaKGiaM3ibgXH4EicsMTm2weh3DGh5UomicyRGQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="逛官网，读文档"><a href="#逛官网，读文档" class="headerlink" title="逛官网，读文档"></a>逛官网，读文档</h2><p>首先来到hexo官网，你要折腾某个东西的时候，它的官网是一定要逛的。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66oV6oiaicmjefXcWnOGoc2TYUJmbk0WbicOe1yWiaqlxLCRek59czgtPdHA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>找到自定义主题我们可以看到：（请务必认真看完再往后阅读）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66GdMpz4j8yISL1X59bYAvgtF9NIP5Z5sxPXfqsGqkf11BYe7VFXR6gA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="本地新建"><a href="#本地新建" class="headerlink" title="本地新建"></a>本地新建</h2><p>假设你已经看完上图的文档了，开始开发主题了。首先还是要新建一个hexo博客，在卡在这一步的时候就可以Ctrl+C停止了。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66OvS11hXiaviafktnyXhibLic2biaQqGe8o9JjUnK3LXk8iarBly92HrU4Sog/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>用subline打开新建好的博客(Story)，可以看到在themes目录下空空如也，反正我们准备自己开发一个，空的正好。<br>这个时候就要想到文档里的目录结构了：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66G88F2LicWvRoHpZu2CbV45I3Pef3iciaSsZl2WuuBBXulAzaNkpANAEHA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>新建如下：（当然要给主题建个目录，这里就叫story好了）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66pjFziaWd6B5ZMTicCk7dGF0qyzPyBI3vIEw4bCSUMU8q4N2Z3pSiaDVIg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>建好这后记得上级目录的_config.yml里面修改配置：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66bN6mIsVwce2oHiaRf4dBFxj2dnl55I4wLerUh7fcv1u8gxFUGOEonHg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>有好奇的小伙伴可以试着运行看看：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u663e95aXFkkoL8QcX6WuB1DrFZ7ku1We57Nf2WrgE5EdKX06BEcR3DVg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>不要担心，这是我们没有用npm安装依赖，因为上一步的时候直接ctrl+c跳过了。使用npm i命令安装。（有切换过淘宝镜像的可以使用cnpm i安装，npm安装淘宝镜像自行百度）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66ohuQ9hm51klBKjraLD3rtNpZCtWIwxQx4reIMJ33Xic2CQX93psF8bQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>可以看到安装成功后使用hexo s发布真的能跑起来，不过当我们访问的时候就会报No layout: index.html这个错。简单理解下它意思，没有layout(布局，或者说模版):index.html。</p><h2 id="选择模板引擎"><a href="#选择模板引擎" class="headerlink" title="选择模板引擎"></a>选择模板引擎</h2><p>那么我们就应该建一个layout来展示index.html。不过在建之前要先确定用哪种模版引擎，官方文档如是说到：Hexo 内建 Swig 模板引擎，您可以另外安装插件来获得 EJS、Haml 或 Jade 支持。这里为了简单，学习成本低，采用了ejs模板引擎。文档也说的很明白了，用ejs我们还要安装。不过看了下package.json，hexo4.0已经集成了hexo-renderer-ejs，所以用ejs也不用安装了，直接用就是。（Jade等还是要另外安装插件的）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwetbsqfNUzTRqGfVgsF6u66mXX9Mwh95fibkh8fVjhY6GEn997PmJuFiceptKBNY34bjoE7DqXOSNCw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="构建主题页面"><a href="#构建主题页面" class="headerlink" title="构建主题页面"></a>构建主题页面</h2><p>模板引擎选好之后，就可以新建模版页面了。在新建前要好好看下官方文档的模版说明。看完之后可以自己构思下怎么做<br>t</p><p>h</p><p>i</p><p>n</p><p>k</p><p>i</p><p>n</p><p>g</p><p>想不出来的可以参考下别人或者官方的主题是怎么做的。</p><h2 id="构建主题页面-1"><a href="#构建主题页面-1" class="headerlink" title="构建主题页面"></a>构建主题页面</h2><p>我们在阅读文档模版后，可以知道如下信息：</p><blockquote><p>模板决定了网站内容的呈现方式，每个主题至少都应包含一个 index 模板，以下是各页面相对应的模板名称：</p></blockquote><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SWIw5MOMKibqyTWvib2r8nmRzxVUlia4tkAX0LaIh0ryElOHm0QpPQfSWQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><blockquote><p>布局（Layout），如果页面结构类似，例如两个模板都有页首（Header）和页脚（Footer），您可考虑通过「布局」让两个模板共享相同的结构。一个布局文件必须要能显示 body 变量的内容，如此一来模板的内容才会被显示，举例来说：</p></blockquote><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5Sk9sUe2WBzLyiaakS1uYPx9SCFagCldH27mnjdtm8pN2d7BH6mGBCjDA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><blockquote><p>每个模板都默认使用 layout 布局，您可在 front-matter 指定其他布局，或是设为 false 来关闭布局功能，您甚至可在布局中再使用其他布局来建立嵌套布局。</p></blockquote><p>关于front-matter可以查下以下文档了解更多front-matter</p><pre><code>Front-matter 是文件最上方以 --- 分隔的区域，用于指定个别文件的变量，举例来说：---title: Hello Worlddate: 2013/7/13 20:46:25---</code></pre><p>根据以上文档，我们就可以建模版页面了。其中<code>每个主题至少都应包含一个 index 模板</code>和<code>每个模板都默认使用 layout 布局</code>，所以我们先建个layout.ejs和index.ejs<br>index.ejs内容如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SvymxaHOCcRbjMIDJlBicxS4HD4CcbQtCyMplPmSk1MjUXTflH48JjLw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>layout.ejs内容如下：其中<code>&lt;%- body %&gt;</code>文档中并没有做出详细解释，可以理解body为页面内容。首页就是引入index.ejs，归档页就是引入archive.ejs这样。至于<code>&lt;%- %&gt;</code>的语法可以去参考ejs文档(看不懂的，就是没好好看文档。)<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SwVwcXMHqYnekVEeVGc5P9UeDAtBemVUInh7tNeDib73BcRoHibny3fHg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>hexo s 生成运行如下，可以看到我们的模版页编译成功了。（生成了layout的头部和尾部，并成功显示出了index中的内容）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5S0gYAbhXYot3El5kStqiaDKNhThvdEleQIZYQfk0JJu8aehIpqTDpP1Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>好了，主题页面就是这样构建的，接下来开始把从html5up上下载的story写成我们的主题。</p><h2 id="构建-hexo-theme-story-首页"><a href="#构建-hexo-theme-story-首页" class="headerlink" title="构建 hexo-theme-story 首页"></a>构建 hexo-theme-story 首页</h2><p>解压得到：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SqCEFd5j65Rya8kRXcORicBEF2ps2BoHgBMxWBTGJiaS0MRwKk4h9zmSA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>在subline中打开其index页面如下<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SeH34S9qfLy6Nuqd8zR6mZr5cIo1YIJvWHpS8ZB5KqqgnJPgbwTsLFA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>我们要拆解这个页面，从简单的header和footer开始，将其代码收缩，可以就大致分出header、body、和footer了。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SfSB4TVCg8rcSnXoeVMH7Zic8l7l8cG5pGNyD0Hib6Ffr0NpLPUIhLibEA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>再看官方文档中关于局部模版的说明，我想你已经学会怎么拆分了<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SWCtMjPzqFUX8ib1F7qNIicQGmKlBRA1cwiaWev2mhYYAmo6k26PRiat7IQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>文件夹这样建立：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5Sx7QnNuBpOS9Q00ZrCHuKiciajJ7tiaBXicIe0elEiaqqGKagnMl65bjrKLg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>稍难点的layout这样写：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5ScjSRfULCwiamo2YGtyqISo9nypQSxsorgamg2FfMBE0tfb4vNxegsOQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>但是这样拆分还是有些问题，比如有部分的footer内容在index中，暂时把这部分代码直接剪切到footer.ejs中<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SGXsMv7LEicxS9ibkrzjO0ibHbwzubEpkBdkU48W3zS6hmKZGoVgBvxrgw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>运行后页面如下所示：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SiaX2RoPwvhmewK3uYQCwWPhxRSaGYU1wYltEFxtEdAJO9dZ0R7XNzGg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>页面这种显示的原因是我们没有导入js、css。</p><h2 id="导入css、js"><a href="#导入css、js" class="headerlink" title="导入css、js"></a>导入css、js</h2><blockquote><p>source<br>资源文件夹，除了模板以外的 Asset，例如 CSS、JavaScript 文件等，都应该放在这个文件夹中。文件或文件夹开头名称为 _（下划线线）或隐藏的文件会被忽略。<br>如果文件可以被渲染的话，会经过解析然后储存到 public 文件夹，否则会直接拷贝到 public 文件夹。</p></blockquote><p>所以我们的 CSS、JavaScript、Images 文件要放在source文件夹中，怎么放我就不赘述了。说说怎么引入。可以hexo g先生成public文件夹，看一下目录结构：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SaMwJIVvptKmUdkVrSGTchrr4UrJBAK5BlUD9q0UHRiaqhjicsBH97GWA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>可以看到对于最外层的index.html来说，引入可以使用更通用的相对路径写法<code>./css/xxx.css</code>(./表示当前目录下)，但是这种写法放在hello-world下的文章页index.html就不适用了。必需使用绝对路径写法<code>/css/</code>（/表示从根目录开始）所以可以使用如下写法引入：</p><pre><code class="html">&lt;link rel=&quot;stylesheet&quot; href=&quot;/css/main.css&quot; /&gt;&lt;noscript&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;/css/noscript.css&quot; /&gt;&lt;/noscript&gt;</code></pre><p>但是这种写法也有一个问题，若你的博客不是放在网站根目录也是不生效的。所以hexo辅助函数css()，js()就有意义了。</p><pre><code class="ejs">&lt;%- css(path, ...) %&gt;&lt;%- js(path, ...) %&gt;</code></pre><p>最终改写成如下：</p><pre><code class="html">&lt;head&gt;  &lt;title&gt;Story by HTML5 UP&lt;/title&gt;  &lt;meta charset=&quot;utf-8&quot; /&gt;  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, user-scalable=no&quot; /&gt;  &lt;%- css([&#39;/css/main.css&#39;, &#39;/css/noscript.css&#39;]) %&gt;&lt;/head&gt;</code></pre><p>js雷同。<br>把layout中的注释改成html注释，hexo s 运行预览下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwf5qXudsPYOVrfldHecZK5SgDlWE1qicd3p4V3sDTbO5iccyWXeRWtmJlqP7LrCmSLc74WkRtdBWEyg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>可以看到页面已经正常了，图片路径自行修改下就可以呈现。<br>从这教成开始代码开始变多起来，我把代码同步上传到github仓库和百度云上，~关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story002获取。</p><p>我们已经搭建好了首页，上篇教程已经引入了css和js，接下来还是引入网站上的一些图标。</p><h2 id="引入图标"><a href="#引入图标" class="headerlink" title="引入图标"></a>引入图标</h2><p>上篇教程自行引入图片其实是不用的，因为我们建立的图片文件夹正好是images，和原来的html5up模板刚好一致。让我们看下代码：</p><pre><code class="html">&lt;div class=&quot;image&quot;&gt;  &lt;img src=&quot;images/banner.jpg&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</code></pre><p>但是也和之前的问题一样，用这种的话一定要把网站放到根目录访问，所以可以用到hexo的辅助函数“url_for”，<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UcgsHl1micMic4J5qjEUkK1iaibMknDTp7vcErJ5ia6oX3ibpDZ9PhsK5IV3Rw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>img代码改成如下即可：</p><pre><code class="html">&lt;div class=&quot;image&quot;&gt;  &lt;img src=&quot;&lt;%- url_for(&#39;/images/banner.jpg&#39;) %&gt;&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</code></pre><p>接下来回到正题，引入图标，首先确定下这个模板的图标是字体图标，字体文件在webfonts文件夹下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UcOUVGUr4bBVjSmwPaCaqIEg2UQTEic7rvzcHVPB0SVdgjfLe2l8ewI4A/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>为了方便，就直接把这个文件夹复制到主题source下，hexo s 后就可以看到图标已经呈现出来了<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1Uc998BZqsUGTuWjjOFgkHrSzJDYmZJUOdCviapiahxmFsvgCSbrXCicrG8w/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="完善首页"><a href="#完善首页" class="headerlink" title="完善首页"></a>完善首页</h2><p>开始着手完善首页，首先删掉一些不需要的元素<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1Uc6lgWoR3YEgTWic9wcAXRHaTL3kKeicrdNoJ0dh8icmwYOyg86CwKSwpYw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>在index.ejs中的这个Five、Six、Seven分别是图集、图标、留言部分，首页不需要这些，我们给它删掉。<br>接下来看剩下的代码：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UcKYC87nPgfNmBFh27RdG7loLhTQ9c7V5nRfbzdsJ1A0XREpZ0tspnOA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>one是最上面的那个，图片占一半那种。自成一派先不管。two、three、four则是下面的部分。我们可以给它看做是文章列表。可以看出这几个的元素都一致，就是three的class是orient-left，所以可以删除多余的three、four后网页显示如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1Ucw38Xv5s12y9MuffskjV80cAIHtXqrotYAKOib8UGaCFGSn5p87LRdnQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>接下来考虑往首页填充内容了。不过在这之前还有很多东西要讲下（后悔用文章教程了，出视频的话会快很多55555）</p><p>首先，分析下我们首页或者说文章需要哪些东西。标题、封面图、简介还有一些给我们的如分类、标签、时间等等。这些东西都要我们自己建吗？hexo给了我们一个Scaffold文件夹，在官方文档的写作里面有说明：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UccgLMkg9uyDALAwFmiaRoickYyJhkSW0Q4tw8TSMlnyRHiazSsXMyiagFdA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>打开scaffolds&gt;post.md(就是新建文章的模板)可以看到如下内容：（顺带再提，这个在hexo中叫Front-matter）</p><pre><code>---title: {{ title }}date: {{ date }}tags:---</code></pre><p>可以看到hexo给文章模板预置了title、date、tags，但是我们还需要封面图、简介、分类等等，我们直接修改post.md就可以让hexo生成我们想要的模板。修改的模板如下：(keywords是关键字，对网站seo有好处)</p><pre><code>---title: {{ title }}date: {{ date }}tags:categories:keywords:description:photos:---</code></pre><p>这里为了更方便我们可以给一些项预设初值。比如分类和封面图。</p><pre><code>---title: {{ title }}date: {{ date }}tags:categories: 技术keywords:description:photos: /images/pic01.jpg---</code></pre><p>好了，接下来可以使用 hexo n “你想要的文章名” 来创建文章了。这里我们创建了八篇文章：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UcKicRrOicLddofPg4GwQ2FCShrY0dMZsRWUV2SRy7JWicDU7zyUFStZJqQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>记住把第一个hello world.md删掉，因为这个是hexo init生成的，在它的Front-matter中没有一些项，不删除可能会导致一些错误。<br>好了，测试文章也有了，现在我们要去给首页填充起来。现在我们再来看index.ejs中的one和two,发现one其实和three一样是orient-left，不过多了个fullscreen的css，所以可以只剩下一个two。修改后two的代码如下：</p><pre><code class="ejs">&lt;!-- Two --&gt;&lt;% page.posts.each(function(post){ %&gt;  &lt;section class=&quot;spotlight style1 orient-right content-align-left image-position-center onscroll-image-fade-in&quot;&gt;    &lt;div class=&quot;content&quot;&gt;      &lt;h2&gt;&lt;%= post.title %&gt;&lt;/h2&gt;      &lt;p&gt;&lt;%= post.description %&gt;&lt;/p&gt;      &lt;ul class=&quot;actions stacked&quot;&gt;        &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;button&quot;&gt;Learn More&lt;/a&gt;&lt;/li&gt;      &lt;/ul&gt;    &lt;/div&gt;    &lt;div class=&quot;image&quot;&gt;      &lt;img src=&quot;&lt;%= post.photos %&gt;&quot; alt=&quot;&quot; /&gt;    &lt;/div&gt;  &lt;/section&gt;&lt;% }) %&gt;</code></pre><p>其中each/forEach函数（和js中的each差不多）参考model.js和query.js，post参考变量。<img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1Ucfglhib2hyhRCJO30N1QqYSrWhEicUibclib2kiaiayFXGny7OFQJvhIg8czQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>hexo s后生成如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1Uc4JrZLIxA2w0Mz3p3eEW2UL4czx8HbzcianoZmg0tKn8iceFicc7GYF78g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>怎样将它弄成之前那种左右交替呢？最简单的可以使用css控制：</p><pre><code class="css">.spotlight.style1:nth-child(even) {  -moz-flex-direction: row-reverse;  -webkit-flex-direction: row-reverse;  -ms-flex-direction: row-reverse;  flex-direction: row-reverse;}.spotlight.style1:first-child{    min-height: 100vh;}.spotlight.style1:first-child .image{    width: 50%;}</code></pre><p>稍微解释一下这个css,</p><blockquote><p>nth-child(n) 选择器匹配属于其父元素的第 N 个子元素，不论元素的类型。<br>odd 和 even 是可用于匹配下标是奇数或偶数的子元素的关键词（第一个子元素的下标是 1）。<br>使用公式 (an + b)。描述：表示周期的长度，n 是计数器（从 0 开始），b 是偏移值。</p></blockquote><p>就是匹配.spotlight.style1这俩class的元素。even表示偶数，就表示偶数项为row-reverse（设置</p><p>元素内弹性盒元素的方向为相反的顺序，参考flex布局），奇数项为row。所以就能实现左右左右的效果。而first-child则表示第一项，100vh表示 “相对于视口的高度，视口被均分为100单位的vh” 即铺满屏幕。最终效果如下<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdBKiamAvULZUXIKRc4dc1UceFWfeic0Yx9WWm4AJBwXszuhBNR3phg3ljyQJ8lhjuFlcQzJfA8YvYw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story003获取。</p><h2 id="添加分页"><a href="#添加分页" class="headerlink" title="添加分页"></a>添加分页</h2><p>上篇教程已经把首页内容给填充上去了，接下来继续给首页添加上分页。在文档辅助函数里有关如下<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsB4DIW2Ox0ssRjTlSFkOMT6oWiaiaAv0bt5INc3zcDVR9DPQJCzIiao7Zug/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>直接复制这段代码到index.ejs最下面:</p><pre><code class="ejs">&lt;div class=&quot;paginator&quot;&gt;  &lt;%- paginator({    prev_text: &#39;&lt;i class=&quot;fa fa-angle-left&quot;&gt;&lt;/i&gt;&#39;,    next_text: &#39;&lt;i class=&quot;fa fa-angle-right&quot;&gt;&lt;/i&gt;&#39;,    escape: false  }) %&gt;&lt;/div&gt;</code></pre><p>为了看到效果将根目录下config中的per_page改为三，表示每页三篇文章，这样我们八篇文章就会有三页了</p><pre><code class="yml">index_generator:  path: &#39;&#39;  per_page: 3  order_by: -date</code></pre><p>hexo s后的效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsB1pRibaPxO7L3QCClibX5vlBNdiboD0xVZCSeFUibCbnYaFxJgLTvrn3Yeg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>样式有点不能忍受，用f12工具查看其html代码如下：</p><pre><code class="html">&lt;div class=&quot;paginator&quot;&gt;  &lt;span class=&quot;page-number current&quot;&gt;1&lt;/span&gt;  &lt;a class=&quot;page-number&quot; href=&quot;/page/2/&quot;&gt;2&lt;/a&gt;  &lt;a class=&quot;page-number&quot; href=&quot;/page/3/&quot;&gt;3&lt;/a&gt;  &lt;a class=&quot;extend next&quot; rel=&quot;next&quot; href=&quot;/page/2/&quot;&gt;&lt;i class=&quot;fa fa-angle-right&quot;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/div&gt;</code></pre><p>为了方便直接在index.ejs中写css如下：(最终效果如下图)</p><pre><code class="css">&lt;style&gt;  .paginator {    margin-top: 2em;    width: 100%;    text-align: center;  }  .paginator .page-number{    display: inline-block;    border-radius: 50%;    font-size: 0.8em;    font-weight: 600;    height: 2em;    line-height: 2em;    margin: 0 0.125em;    min-width: 2em;    padding: 0 0.5em;    text-decoration: none;  }  .paginator .current{    box-shadow: inset 0 0 0 1px #47D3E5;    color: #47D3E5 !important;  }&lt;/style&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsBib2En7LoxaNLZib7zoama77Ra2dGmPAZ5qjGqgX2MBtwvTNcnMjRH8ZA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="添加文章详情页"><a href="#添加文章详情页" class="headerlink" title="添加文章详情页"></a>添加文章详情页</h2><p>首先在_partial下新建article.ejs，里面代码如下：（story居然没有文章页的模板233，果然好模板都被人用了）</p><pre><code class="ejs">&lt;article&gt;  &lt;%- page.content %&gt;&lt;/article&gt;</code></pre><p>然后在index.ejs中的a标签中加入文章超链接：</p><pre><code class="html">&lt;div class=&quot;content&quot;&gt;  &lt;h2&gt;&lt;a href=&quot;&lt;%- url_for(post.path) %&gt;&quot;&gt;&lt;%= post.title %&gt;&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;&lt;%= post.description %&gt;&lt;/p&gt;  &lt;ul class=&quot;actions stacked&quot;&gt;    &lt;li&gt;&lt;a href=&quot;&lt;%- url_for(post.path) %&gt;&quot; class=&quot;button&quot;&gt;Learn More&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/div&gt;</code></pre><p>那么怎样让文章页能更根据我们的article.ejs页生成呢？回到一开始的模板介绍：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsBlxXAWiaptZ6r0k75kmGTdibloPXShvmBs24S4QJY6QqTibwnCYjUicsWRQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>按照hexo的文档来，post是用来显示文章的，我们在layout目录下新建这几个ejs(post、page、archive、category、tag），然后暂且把article中的内容复制到post.ejs下，hexo s预览下效果：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsBUsJG1bsJGZ6RWAY5l3xAn5FU65Qv1ibVgc4RkeJJUxIz0yHP0rf0kYg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>已经是能渲染出来了，但是md里面还没有内容，这里我直接把这篇文章的md复制到测试的md中</p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfWibEjPrMjibCxiaaSRAkeZsBw2CUJoicO0tnrSCiaIMAiciaL3axz3YOEzC4lXeWiaZA1Pc3y1SKtJhoHwg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>样式又差不行不行，这个留到下篇教程再美化，现在把之前留下的问题解决，乍一看article.ejs是无用武之地了，不过考虑到page这个单页面的渲染和post差不多一致，所以我们要把文章部分抽离到article.ejs中，这样就可以复用代码了。抽离在教程二中就已经讲到，用局部模版（Partial），代码如下：</p><pre><code class="ejs">&lt;%- partial(&#39;_partial/article&#39;, {post: page}) %&gt;</code></pre><p>后面的{post: page}表示把page变量存到post中传递给了article，所以article中的代码就要改为：</p><pre><code class="ejs">&lt;article&gt;  &lt;%- post.content %&gt;&lt;/article&gt;</code></pre><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story004获取。</p><h2 id="美化详情页"><a href="#美化详情页" class="headerlink" title="美化详情页"></a>美化详情页</h2><p>上篇文章已经可以跳转到文章详情页了，这篇教程先来美化下详情页的样式。<br>首先打开我们从html5up上下载的story网页，浏览器上打开index-demo.html那个，在演示完图标之后有“Additional Elements”<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxFhRgVCjEswJPKNLKHxMDXZibnV3H83jJ9Qw3PFZ7DGRb91eWiaV9e1ng/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>可以看到这部分用来当文章详情页的容器挺合适。修改代码如下：</p><pre><code class="ejs">&lt;article class=&quot;wrapper style1 align-left&quot;&gt;  &lt;div class=&quot;inner&quot;&gt;    &lt;%- post.content %&gt;  &lt;/div&gt;&lt;/article&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxVDQ0sPzjNyZnxEmebicjqlpV3fALwxs1Zw6jgMk2KmLcULOVcAW4nMg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>可以看出这个页面还缺一些必要的内容，如标题。添加后如下：</p><pre><code>&lt;article class=&quot;wrapper style1 align-left&quot;&gt;  &lt;div class=&quot;inner&quot;&gt;    &lt;div class=&quot;header&quot;&gt;      &lt;h1 class=&quot;title&quot;&gt;&lt;%- post.title %&gt;&lt;/h1&gt;      &lt;div&gt;        &lt;span&gt;日期：&lt;%- post.date %&gt;&lt;/span&gt;        &lt;span&gt;字数：&lt;%- post.count %&gt;&lt;/span&gt;      &lt;/div&gt;    &lt;/div&gt;    &lt;%- post.content %&gt;  &lt;/div&gt;&lt;/article&gt;</code></pre><p>main.css</p><pre><code class="css">/* 添加的css项 */.title {  font-size: 3rem;  font-weight: 700;}article h2 {  font-size: 1.7rem;}</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxoLuAGH1A9hOHMgDla6ThU5FeicjGE5zAgyRmwlkGBDJAun1TxZyp2Wg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="解决日期和字数显示"><a href="#解决日期和字数显示" class="headerlink" title="解决日期和字数显示"></a>解决日期和字数显示</h2><p>可以看到网页上的日期显示的是一串数字，其实这个是日期的时间戳</p><blockquote><p>百度百科：时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。通俗的讲， 时间戳是一份能够表示一份数据在一个特定时间点已经存在的完整的可验证的数据。它的提出主要是为用户提供一份电子证据， 以证明用户的某些数据的产生时间。在实际应用上， 它可以使用在包括电子商务、 金融活动的各个方面， 尤其可以用来支撑公开密钥基础设施的 “不可否认” 服务。</p></blockquote><p>来到hexo官网，搜索date:<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxqn31wDXGndwd5HriaennYkJuYpNk26H1NylfcSfYSgelOkH31I2qSvw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxS9VZiaiaXoh27CTs5mqVjXDzMNPcKEak5FqOFUWCz96akXLBwpBZZtHw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>修改成下图：</p><pre><code>&lt;span&gt;日期：&lt;%- date(post.date, &#39;YYYY/M/D&#39;) %&gt;&lt;/span&gt;</code></pre><p>页面显示如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxgNzOKC4z3OhMKjrH2WvygpfIEaQibZ1icPIQ6w961ZfIxribTp5zblKjg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>和官方例子不一样，应该是文档错了。那如果要文档里那种显示该如何修改代码呢？接下来部分是干货，会举一反三的话能自己解决很多问题。分析下，date()这个函数归类在辅助函数helper里。所以先去找有没有hexo-helper-date的包，（在node_modules里找）。没找到，因为这个官方的辅助函数，试着在hexo-cli和hexo里面找。在<a href="mailto:node_modules_hexo@4.2.0" target="_blank" rel="noopener">node_modules_hexo@4.2.0</a>@hexo\lib\plugins\helper\中找到我们要的date.js这个文件。打开它可以看到<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxys1eebZqlo9XXITWqXFQn4MefMibuLjhrunUWVUNT5icjRgghkVAtAwA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img">它都原封不动的调用了 Moment.js，所以我们在hexo文档中直接点击date说明上面那个 Moment.js 的超链接去看 Moment.js 文档。找到了如下表：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwx9D8t7Micp6CKI8Ir1Fxb0K18nHYBjHS6Z4ZQv1UZ0Vic2stYuQchZPNA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>那就简单了，改成自己想要的日期显示类型就行。参考如下：</p><pre><code>&lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD, YYYY, dddd &#39;) %&gt;&lt;/span&gt;</code></pre><p>接下来改成中文月份，只要在根目录的config下把language改为zh-cn即可。(为啥知道，看文档和源)</p><p>日期解决后就要来看下字数，现我们已经知道文章内容在post.contant里。用post.content.length这种写法会把html标签也算进去，hexo给我们提供了strip_html字符串处理函数：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxs26O7VtmOfDYTjIPx5HNWfnjHh0GeKxZiaeWIibYUsrSFEdmbZcNlE4g/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>所以只要strip_html(post.content).length这种写法就好了。效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVweTW3WEhquqOHoCGkma1zwxiaLFBMibLdlqXlNBqwy6icpeybNj9MX2CpBsOHRGxtEy9BMib8fDEyvaLw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story005获取。</p><h2 id="添加阅读次数"><a href="#添加阅读次数" class="headerlink" title="添加阅读次数"></a>添加阅读次数</h2><p>阅读次数采用不蒜子来实现</p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdqzAlcDm1Dw5YTtZtiax0MqvxyuULKDuaVglAD99ic9k06PlBvFrQ1FjwKZEGMX8qZm96NTQJICvqw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>复制这两行代码，引入js的那段放到footer.ejs中，span的那段放在文章详情页中。</p><pre><code>&lt;article class=&quot;wrapper style1 align-left&quot;&gt;  &lt;div class=&quot;inner&quot;&gt;    &lt;div class=&quot;header&quot;&gt;      &lt;h1 class=&quot;title&quot;&gt;&lt;%- post.title %&gt;&lt;/h1&gt;      &lt;div class=&quot;stuff&quot;&gt;        &lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD, YYYY&#39;) %&gt;&lt;/span&gt;        &lt;span&gt;字数  &lt;%- strip_html(post.content).length %&gt;&lt;/span&gt;        &lt;span id=&quot;busuanzi_container_site_pv&quot;&gt;阅读 &lt;span id=&quot;busuanzi_value_site_pv&quot;&gt;&lt;/span&gt;&lt;/span&gt;      &lt;/div&gt;    &lt;/div&gt;    &lt;%- post.content %&gt;  &lt;/div&gt;&lt;/article&gt;</code></pre><h2 id="添加valine评论"><a href="#添加valine评论" class="headerlink" title="添加valine评论"></a>添加valine评论</h2><p>前往valine.js.org官网，查看文档：<br><img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==" alt="img"><br>关于valine和leandcloud一些配置项请参考另一篇文章《hexo评论系统之valine快速使用》，这里就不赘述了。假设你已经有了API_ID和API_Key了，我们先把valine官方文档快速开始中的html片段复制到article.ejs(即文章详情页中)，因为我们是在页面body中了，所以要把head和body删掉，修改后代码如下:</p><pre><code class="ejs">&lt;!-- valine评论 --&gt;&lt;script src=&#39;//unpkg.com/valine/dist/Valine.min.js&#39;&gt;&lt;/script&gt;&lt;div id=&quot;vcomments&quot;&gt;&lt;/div&gt;&lt;script&gt;  new Valine({    el: &#39;#vcomments&#39;,    appId: &#39;&lt;API_ID&gt;&#39;,    appKey: &#39;&lt;API_Key&gt;&#39;  })&lt;/script&gt;</code></pre><p>接下来可以把API_ID和API_Key填入就可以使用了，不过这是开发主题，所以最好要把这些变量在配置里面赋值。在主题下的config里面输入如下：</p><pre><code class="yml">valine:  API_ID: 这里填你的API_ID  API_Key: 这里填你的API_Key</code></pre><p>接着修改valine部分代码如下：</p><pre><code class="ejs">&lt;!-- valine评论 --&gt;&lt;script src=&#39;//unpkg.com/valine/dist/Valine.min.js&#39;&gt;&lt;/script&gt;&lt;div id=&quot;vcomments&quot;&gt;&lt;/div&gt;&lt;script&gt;  new Valine({    el: &#39;#vcomments&#39;,    appId: &#39;&lt;%- theme.valine.API_ID %&gt;&#39;,    appKey: &#39;&lt;%- theme.valine.API_Key %&gt;&#39;  })&lt;/script&gt;</code></pre><p>网页上显示如下:<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdqzAlcDm1Dw5YTtZtiax0MqmNtUHgicl4DgYzHglBQ3y0Tya3lPv76m1icaBo0jRAXAweDCgsOsbX6Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>valine评论的样式乱了，使用f12工具发现main.css把input元素设为了块级元素（还有其他一些问题），所以在css中加入</p><pre><code class="css">#vcomments input {  display: inline-block;}#vcomments button {  height: 2.25rem;}</code></pre><h2 id="添加评论数"><a href="#添加评论数" class="headerlink" title="添加评论数"></a>添加评论数</h2><p>因为在valine的显示中是有评论数这个选项的。但文档里面并没有给我们提供这个接口，所以我们可以自行调用valine的函数来获取。代码如下:（看源码无所不能）</p><pre><code class="ejs">&lt;article class=&quot;wrapper style1 align-left&quot;&gt;  &lt;div class=&quot;inner&quot;&gt;    &lt;div class=&quot;header&quot;&gt;      &lt;h1 class=&quot;title&quot;&gt;&lt;%- post.title %&gt;&lt;/h1&gt;      &lt;div class=&quot;stuff&quot;&gt;        &lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD, YYYY&#39;) %&gt;&lt;/span&gt;        &lt;span&gt;字数 &lt;%- strip_html(post.content).length %&gt;&lt;/span&gt;        &lt;span&gt;评论 &lt;span id=&quot;valine-count&quot;&gt;&lt;/span&gt;&lt;/span&gt;        &lt;span id=&quot;busuanzi_container_site_pv&quot;&gt;阅读 &lt;span id=&quot;busuanzi_value_site_pv&quot;&gt;&lt;/span&gt;&lt;/span&gt;      &lt;/div&gt;    &lt;/div&gt;    &lt;%- post.content %&gt;    &lt;!-- valine评论 --&gt;    &lt;script src=&#39;//unpkg.com/valine/dist/Valine.min.js&#39;&gt;&lt;/script&gt;    &lt;script src=&#39;//cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js&#39;&gt;&lt;/script&gt;    &lt;div id=&quot;vcomments&quot;&gt;&lt;/div&gt;    &lt;script&gt;      var valine = new Valine();      valine.init({        el: &#39;#vcomments&#39;,        appId: &#39;&lt;%- theme.valine.API_ID %&gt;&#39;,        appKey: &#39;&lt;%- theme.valine.API_Key %&gt;&#39;      })      valine.Q(location.pathname.replace(/index\.html?$/, &#39;&#39;)).count().then(num =&gt; {        document.getElementById(&quot;valine-count&quot;).innerHTML = num;      })    &lt;/script&gt;  &lt;/div&gt;&lt;/article&gt;</code></pre><p>效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdqzAlcDm1Dw5YTtZtiax0MqWYeKc1qke6fLJrDhrhnhib97ClDKrl8TiaL8hMpwcCdZbKC9EibezDh6Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="添加上一篇和下一篇"><a href="#添加上一篇和下一篇" class="headerlink" title="添加上一篇和下一篇"></a>添加上一篇和下一篇</h2><p>这里直接使用了自己当前主题的代码，这个功能实现起来只要知道hexo官方文档中page变量就行：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdqzAlcDm1Dw5YTtZtiax0MqUg9QUQEI1kFdcgNrCAp3ydWlPYSnleHs71G7zIZqjDoFpDddibGQVNw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>代码和效果如下:</p><pre><code class="ejs">&lt;div class=&quot;post-nav&quot;&gt;    &lt;% if (post.prev){ %&gt;    &lt;div class=&quot;post-nav-prev post-nav-item&quot;&gt;        &lt;a href=&quot;&lt;%- url_for(post.prev.path) %&gt;&quot; &gt;&lt;%= post.prev.title %&gt;&lt;i class=&quot;fa fa-chevron-left&quot;&gt;&lt;/i&gt;&lt;/a&gt;    &lt;/div&gt;    &lt;% } %&gt;    &lt;% if (post.next){ %&gt;    &lt;div class=&quot;post-nav-next post-nav-item&quot;&gt;        &lt;a href=&quot;&lt;%- url_for(post.next.path) %&gt;&quot; &gt;&lt;%= post.next.title %&gt;&lt;i class=&quot;fa fa-chevron-right&quot;&gt;&lt;/i&gt;&lt;/a&gt;    &lt;/div&gt;    &lt;% } %&gt;&lt;/div&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdqzAlcDm1Dw5YTtZtiax0MqmNtUHgicl4DgYzHglBQ3y0Tya3lPv76m1icaBo0jRAXAweDCgsOsbX6Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story006获取。</p><h2 id="添加文章标签"><a href="#添加文章标签" class="headerlink" title="添加文章标签"></a>添加文章标签</h2><p>打算在hr的上边添加文章的标签，用f2开发者工具调试如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQCQh1NewX7O3EEEic2ncQaevianKrsEHjibuT7v5jqXfpMoKAv2vr3YLqA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>先到css的8551行把margin调为0：</p><pre><code class="css">hr {    margin: 0 0 0 0;}</code></pre><p>接着在hr上面添加html元素，先写好再调样式：</p><pre><code class="html">&lt;div class=&quot;tags&quot;&gt;  &lt;span&gt;标签：&lt;/span&gt;  &lt;a href=&quot;&quot; class=&quot;tag&quot;&gt;XX标签&lt;/a&gt;  &lt;a href=&quot;&quot; class=&quot;tag&quot;&gt;XX标签&lt;/a&gt;&lt;/div&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQ9PsAPJEYWzDrfdDA97QETyUD3F2qagLO1WCpeqxqckSFuAqvf7gL3A/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>再写css，可以自行添加一些交互效果，自由发挥：</p><pre><code class="css">.tags a {  font-size: 15px;  padding: 3px 5px;  text-decoration: none;}.tags a:hover{  color: #fff;  background: #333;}</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQMhNkQThDWZjWhicdloYhBMFES4M8DrJ60ic0MzySzVdhNriap9oVcq6PQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>当然现在的标签不是文章设置的标签，来到官网可以看到：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQ7QfxDCiaTEy58wpgUSevl8lQYiaM7tGTTNXyicnoaTtlACXlBHXciattVA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>所以只要把page.tags循环输出即可。</p><pre><code class="ejs">&lt;div class=&quot;tags&quot;&gt;  &lt;span&gt;标签：&lt;/span&gt;  &lt;% post.tags.each(function(tag){%&gt;    &lt;a href=&quot;&quot; class=&quot;tag&quot;&gt;{{ tag.name }}&lt;/a&gt;  &lt;% }) %&gt;&lt;/div&gt;</code></pre><p>当然了，再查看效果前你要给md加上标签才行：</p><pre><code>---title: story6date: 2020-01-18 22:11:30tags: - tag1 - tag2categories: 技术keywords:description:photos: /images/pic01.jpg---</code></pre><p><img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==" alt="img"><br>光显示了名称还不行，还要跳转到相关页面，那url怎么获取呢？官方文档中并未做详细说明，可以去看源码。不过最简单的还是把tag输出就知道了，在tags循环中加入console.log：</p><pre><code>&lt;% post.tags.each(function(tag){%&gt;  &lt;% console.log(tag) %&gt;  &lt;a href=&quot;&quot; class=&quot;tag&quot;&gt;&lt;%= tag.name %&gt;&lt;/a&gt;&lt;% }) %&gt;</code></pre><p>可以看到cmd输出如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQ64XPCXGbnahIlKsLYhggxpXbqvD8Iibjaza6TrBYEjxvSzvemuXGJPA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>所以tag.path就可以获取到url了</p><pre><code>&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;标签：&lt;/span&gt;&lt;% post.tags.each(function(tag){%&gt;  &lt;a href=&quot;&lt;%- url_for(tag.path) %&gt;&quot; class=&quot;tag&quot;&gt;&lt;%= tag.name %&gt;&lt;/a&gt;&lt;% }) %&gt;&lt;/div&gt;</code></pre><h2 id="标签页空白？"><a href="#标签页空白？" class="headerlink" title="标签页空白？"></a>标签页空白？</h2><p>再上一步加好url后，尝试点击标签，会跳转到一个页面:<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQxJyiaTb7XgB8Iu8NWJJkTUzyBfmLqjxLTgf9rIiaU4qPD77VY47DJyzQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>为啥除了footer全是空白。回想一下之前的文章详情页的时候是不是也这样，再次回顾文档：<br><img src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==" alt="img"><br>加上这句：</p><blockquote><p>每个模板都默认使用 layout 布局，您可在 front-matter 指定其他布局，或是设为 false 来关闭布局功能，您甚至可在布局中再使用其他布局来建立嵌套布局。</p></blockquote><p>分析一下，链接跳转tag模板，默认使用layout:</p><pre><code>&lt;html&gt;  &lt;!-- //头部模版 --&gt;  &lt;%- partial(&#39;_partial/header&#39;) %&gt;  &lt;body class=&quot;is-preload&quot;&gt;    &lt;!-- //内容模版 --&gt;    &lt;%- body %&gt;    &lt;!-- //尾部模版 --&gt;    &lt;%- partial(&#39;_partial/footer&#39;) %&gt;  &lt;/body&gt;&lt;/html&gt;</code></pre><p>所以在加载了footer和header(header只是引用css等，不会在页面显示)，然后&lt;%- body %&gt;加载了tag模板。而我们的tag模板里啥都没有，所以显示空白。</p><h2 id="tag页模板"><a href="#tag页模板" class="headerlink" title="tag页模板"></a>tag页模板</h2><p>tag页怎么建好呢，没想好的可以参考下其他主题点击标签后的效果。等你想好前可以试着验证下上一步的分析推论，在tag.ejs下加入如下代码：(可以看到页面出来了)</p><pre><code class="html">&lt;h1&gt;This is Tags page&lt;/h1&gt;&lt;h1&gt;This is Tags page&lt;/h1&gt;&lt;h1&gt;This is Tags page&lt;/h1&gt;&lt;h1&gt;This is Tags page&lt;/h1&gt;&lt;h1&gt;This is Tags page&lt;/h1&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQoO0oJx1GJvmicMicbUwcxyUzvcVSfWjZKpZkEF2hicmykicDXdq2qBk4YQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>回到正题，tags页面应该显示什么？点击某一个标签，一个标签对应n篇文章（至少有一篇）。所以应该显示的是属于该标签下的文章列表页。所以tag.ejs中应该写显示文章列表页的代码，等等！index首页是显示文章列表页，tag是显示文章列表页，将来分类category也是显示文章列表页，我们应该把显示文章列表页部分单独抽离出来。hexo大部分主题用archive来表示文章列表页，但归档页也叫archive，这里为了好理解，就叫post-list好了。<br>在_partial下新建post-list.ejs文件，把index中的文章列表部分代码复制进去。(应该是全部233333，因为首页没其他东西了)<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQ8BB81IjKmPhluwbOJfwNTSunAjbcNYlnKSl4IicflzygaTQKJqf9FxA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>然后index和tag页都只要简单的引用post-list就行了。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwfUJbzBpSW0MMvBLOZAo6CQ5icrxHqWVJvxEqsy0gXZuEOkQhZguUf6Qu0aCpX65hJvSZuLkVBGN6A/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story007获取。</p><h2 id="继续完善文章详情页"><a href="#继续完善文章详情页" class="headerlink" title="继续完善文章详情页"></a>继续完善文章详情页</h2><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdpWG8fTQjsjV05gD7hSTiaD3JISrw4AhFDGSvJstKgdjMw7gkMia3nmgAmKfTQjddd47GSO5nb5qyA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>现在的页面右边留空太多了，整体看上去不够居中。所以调下css:</p><pre><code class="css">article.wrapper.style1 &gt; .inner {  padding: 2rem 2.5rem 3rem 2.5rem;  margin: 50px auto;  width: 960px;  box-shadow: 1px 0px 5px 1px #ccc;}</code></pre><p>接着图片和代码块超出了范围：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdpWG8fTQjsjV05gD7hSTiaDkSUU7UzVGSHNw0kzX1d9NdhaFgHuAIZRAdNCXoUTow9HwUNxS9qnJA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><pre><code class="css">article.wrapper.style1 &gt; .inner img {  width: 100%;}article.wrapper.style1 .highlight {  overflow: auto;}</code></pre><h2 id="hexo-helper-tocbot添加文章目录toc"><a href="#hexo-helper-tocbot添加文章目录toc" class="headerlink" title="hexo-helper-tocbot添加文章目录toc"></a>hexo-helper-tocbot添加文章目录toc</h2><p>如果觉得目录有需要的继续往下看，这里直接安利我之前开发的hexo插件hexo-helper-tocbot及教程<a href="http://mp.weixin.qq.com/s?__biz=MzI2NjE5Nzg4NQ==&amp;mid=2247484082&amp;idx=2&amp;sn=29b6cb808c1d6804994876521b9ce744&amp;chksm=ea908ca0dde705b64e61742117daa2c60ded907e51b77b1b7b11a6d6036c36596f956874c6da&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">hexo-helper-tocbot插件使用教程</a>。</p><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><p>在cmd中使用npm或cnpm安装：</p><pre><code class="shell">npm i hexo-helper-tocbot --save</code></pre><h3 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h3><p>安装好后在主题下的config中添加教程中的配置：</p><pre><code class="yml">tocbot:  contentSelector: .post-content  scrollSmooth: true  headingSelector: h1, h2, h3, h4, h5  headingsOffset: 45  scrollSmoothOffset: -45</code></pre><p>其中headingsOffset和scrollSmoothOffset要和你主题的头部高度相对应。含义详见API</p><p>最后在article.ejs中添下如下代码（注意，这里要把content用</p><p>包起来才能识别）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdpWG8fTQjsjV05gD7hSTiaDuxNWiccb1KeDnWET0okfIQVF0QvxWQ8u1H2Xf7KOWmh8vZo68iccicfeA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="添加返回首页按钮"><a href="#添加返回首页按钮" class="headerlink" title="添加返回首页按钮"></a>添加返回首页按钮</h2><p>网上找了个svg按钮，放上去，然后把a的href改为javascript:history.back(-1)就行，修改后代码如下：（可自由发挥，找更棒的）</p><pre><code>&lt;article class=&quot;wrapper style1 align-left&quot;&gt;  &lt;!-- 返回按扭 --&gt;  &lt;a href=&quot;javascript:history.back(-1)&quot; class=&quot;cd-nav-trigger&quot;&gt;     &lt;span class=&quot;cd-nav-icon&quot;&gt;&lt;/span&gt;    &lt;svg x=&quot;0px&quot; y=&quot;0px&quot; width=&quot;54px&quot; height=&quot;54px&quot; viewBox=&quot;0 0 54 54&quot;&gt;    &lt;circle fill=&quot;transparent&quot; stroke=&quot;#656e79&quot; stroke-width=&quot;1&quot; cx=&quot;27&quot; cy=&quot;27&quot; r=&quot;25&quot; stroke-dasharray=&quot;157 157&quot; stroke-dashoffset=&quot;157&quot;&gt;&lt;/circle&gt;    &lt;/svg&gt;  &lt;/a&gt;   ......  ......</code></pre><p>css:</p><pre><code class="css">/* 返回按钮 */.cd-nav-trigger {  transform: rotate(180deg);}.cd-nav-trigger {  position: fixed;  z-index: 3;  left: 5%;  top: 20px;  height: 54px;  width: 54px;  background-color: #233;  border-radius: 50%;  overflow: hidden;  text-indent: 100%;  white-space: nowrap;  transition: transform 0.5s;}#cd-nav {  color: #9cb3a8;  text-decoration: none;}.cd-nav-trigger .cd-nav-icon {  position: absolute;  left: 50%;  top: 50%;  bottom: auto;  right: auto;  transform: translateX(-50%) translateY(-50%);  width: 22px;  height: 2px;  background-color: #ffffff;}.cd-nav-trigger circle {  stroke-dashoffset: 0;  transition: stroke-dashoffset 0.4s 0.3s;}.cd-nav-trigger circle {  transition: stroke-dashoffset 0.4s 0s;}.cd-nav-trigger .cd-nav-icon::before, .cd-nav-trigger .cd-nav-icon:after {  content: &#39;&#39;;  position: absolute;  top: 0;  right: 0;  width: 50%;  height: 100%;  background-color: inherit;  transform: translateZ(0);  backface-visibility: hidden;  transition: transform 0.5s, width 0.5s;}.cd-nav-trigger .cd-nav-icon::before {  transform-origin: right top;  transform: rotate(45deg);}.cd-nav-trigger .cd-nav-icon::after, .cd-nav-trigger .cd-nav-icon::before {  width: 50%;  transition: transform 0.5s, width 0.5s;}.cd-nav-trigger .cd-nav-icon::after {  transform-origin: right bottom;  transform: rotate(-45deg);}</code></pre><p>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story008获取。</p><p>继续完善主题，老实说能从一跟着练习到这里的人，开发一个自己的hexo主题已经不是什么难事了。（前题有html、js、css[学习这三最快的地方首推w3cshool]）。开发到这里其实已经讲的差不多了。剩下一些功能都是类似或可有可无的。比如分类和标签是类似的，单页面都是一样的，今天我个就来开发一个单页面。</p><h2 id="文章归档单页面"><a href="#文章归档单页面" class="headerlink" title="文章归档单页面"></a>文章归档单页面</h2><p>即archive页，如果还记得之前的教程或有认真看过hexo文档的话，应该知道它是官方给出的六大模板之一。这也是它特殊的地方。如果你打开hexo根目录的package.json的话就能发现：(关于package.json是干啥用自行百度，好奇能使你进步)<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUtp3xIpuJjDaP7k4OXn0Pnq1cJ9oXbaiccOe7icxC3JB8VzSyJveoyiasw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>archive、category、index、tag都在里面，而且都是hexo-generator开头的。那么hexo-generator又是什么呢？来到hexo官网的api页：</p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUFfayURFlTtjHvDQXUBFjVmdsspbmvQ5XTGs7V9YXN4hzy1O2Ntov1Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>而且也举了归档页面的例子来向我们说明:<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUsicmkaprhw2ClJgiahZGTurj6buxUoIichZlhywEoFdcVtibd1JneYEWhg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>认真看懂它。<br>意思是生成archives/index.html这个文件，提供的数据为所有的文章(data: locals.posts,)，渲染的模板是archive，没有archive就用index替补（layout: [‘archive’, ‘index’]）</p><p>好了好了不扯了，关于hexo运行原理一时半会儿也说不完。</p><h2 id="编写代码"><a href="#编写代码" class="headerlink" title="编写代码"></a>编写代码</h2><p>以上扯了这么久就是说我们直接在archive.ejs里面撸代码就行了。嗯嗯网上找了个模板，样子如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUEhMFHH98J0Bf6yFLvE3PGraUH1hSvJ9GdSCNjEHn2RLPxA4ZWh1oOw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>先直接将代码复制到archive.ejs中，在source/css中新建archive.css，把需要的css复制其中。再在archive.ejs中引入，部分代码如下：</p><pre><code class="html">&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;article&gt;    &lt;h3&gt;2013&lt;/h3&gt;    &lt;section&gt;      &lt;span class=&quot;point-time point-yellow&quot;&gt;&lt;/span&gt;      &lt;time datetime=&quot;2013-03&quot;&gt;        &lt;span&gt;March&lt;/span&gt;        &lt;span&gt;2013&lt;/span&gt;      &lt;/time&gt;      &lt;aside&gt;        &lt;p class=&quot;things&quot;&gt;The FAW&lt;/p&gt;        &lt;p class=&quot;brief&quot;&gt;&lt;span class=&quot;text-yellow&quot;&gt;Award&lt;/span&gt; (Miami. FL)&lt;/p&gt;      &lt;/aside&gt;    &lt;/section&gt;    &lt;section&gt;      &lt;span class=&quot;point-time point-red&quot;&gt;&lt;/span&gt;      &lt;time datetime=&quot;2013-03&quot;&gt;        &lt;span&gt;March&lt;/span&gt;        &lt;span&gt;2013&lt;/span&gt;      &lt;/time&gt;      &lt;aside&gt;        &lt;p class=&quot;things&quot;&gt;You reached 500 followers on Twitter&lt;/p&gt;        &lt;p class=&quot;brief&quot;&gt;&lt;span class=&quot;text-red&quot;&gt;Social Appearance&lt;/span&gt;&lt;/p&gt;      &lt;/aside&gt;    &lt;/section&gt;  &lt;/article&gt;</code></pre><p>hexo s后，在浏览器地址栏输入localhost:4000/archives/就能访问到：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUAuwsYo1RGN2YZLbcpwbFMbZTAy7Ga0icev8mcdW5TDTG4iaNRPzkUBGw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img">找到archive的页面变量：（page.year和page.month是undefined，可能哪里需要设置）<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUicV8parwl5vnjFHR0zWLKgmqVBLQ3A4eGIEHVTYcYKNjbZN8efNXJFw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>然后去把测试的md文章都改下时间。万事具备，接下来开始修改html代码：</p><pre><code class="html">&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;% console.log(page)%&gt;  &lt;% page.posts.each(function(post){ %&gt;    &lt;% console.log(post.title)%&gt;  &lt;% }) %&gt;  &lt;article&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUVxKpzGfzzRcpjK7KkIQdUGIxgLicqTI9rOebuKjfztxibUgteuXqgJ6w/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>这里说明一下，8,9,5都是我改了后还是2020年的，2019和2018的不在。说明page.posts是不全的，我们应该用网站变量：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUHlUcqZNbUD27xrCiafVrUib16apD1MkyzgfTZalz3UMtd1uqzCmfkiaSA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><pre><code>&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;% console.log(site)%&gt;  &lt;% site.posts.each(function(post){ %&gt;    &lt;% console.log(post.title)%&gt;  &lt;% }) %&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUNJCBk4FJcJ9Usic0M9iaA4hheFYGFzylTHVsmq5qUHMyJaAICnE8KqZA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>但是可以看出它似乎没有按照时间排序，前面我们有说过page.posts是Model.js的model对像，在Query.js中给我们提供了个sort方法如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUBD6T2siclzKgLyIddJQ55rVP9zQUiazXSrIrRmyIp3Pl63H388Njc60Q/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>所以修改代码如下：</p><pre><code>&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;% console.log(site)%&gt;  &lt;% site.posts.sort(&#39;date&#39;).each(function(post){ %&gt;    &lt;% console.log(post.title)%&gt;  &lt;% }) %&gt;</code></pre><p><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZU7icVtZDY17yX1RyawEwPr2N2JczlNvtn2VAI1ofNBQXlv3P3OdNQsRQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>可以看到已经按时间排序了。</p><p>coding……</p><pre><code>&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;% var tempYear %&gt;  &lt;% var posts = site.posts.sort(&#39;date&#39;) %&gt;  &lt;% posts.each(function(post, i){ %&gt;    &lt;% var currentYear = parseInt(date(post.date, &#39;YYYY&#39;)); %&gt;    &lt;% if (tempYear != currentYear){ %&gt;      &lt;% tempYear = currentYear %&gt;      &lt;article&gt;        &lt;h3&gt;&lt;%- currentYear%&gt;&lt;/h3&gt;    &lt;% } %&gt;        &lt;section&gt;          &lt;span class=&quot;point-time point-yellow&quot;&gt;&lt;/span&gt;          &lt;time datetime=&quot;&lt;%- date(post.date, &#39;YYYY-MM&#39;)%&gt;&quot;&gt;            &lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD,&#39;)%&gt;&lt;/span&gt;          &lt;/time&gt;          &lt;aside&gt;            &lt;p class=&quot;things&quot;&gt;&lt;%= post.title%&gt;&lt;/p&gt;             &lt;p class=&quot;brief&quot;&gt;&lt;span class=&quot;text-yellow&quot;&gt;&lt;%= Object.values(post.categories.data[0])[0] %&gt;            &lt;/span&gt;&lt;/p&gt;          &lt;/aside&gt;        &lt;/section&gt;    &lt;% if (!posts.eq(i + 1) || currentYear != parseInt(date(posts.eq(i + 1).date, &#39;YYYY&#39;))){ %&gt;      &lt;/article&gt;    &lt;% } %&gt;  &lt;% }) %&gt;&lt;/div&gt;</code></pre><p>最后效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwdxTfh1Rq6s8gavhOm6siaZUxT6ia1lVylj8iaXhHdnjKk1lw2LTJ1TZHLe20NuMBqZuiaGAcB15WpW5w/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>如果想让归档列表按照分类显示不同颜色怎么实现呢？</p><p>代码解释和实现方法待续 To be continued……<br>代码同步上传在github仓库和百度云上，关注公众号<a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a>回复story009获取。</p><h2 id="代码解释"><a href="#代码解释" class="headerlink" title="代码解释"></a>代码解释</h2><pre><code class="html">&lt;%- css([&#39;/css/archive.css&#39;]) %&gt;&lt;div class=&quot;content&quot;&gt;  &lt;% var tempYear %&gt;  &lt;% var posts = site.posts.sort(&#39;date&#39;) %&gt;  &lt;% posts.each(function(post, i){ %&gt;    &lt;% var currentYear = parseInt(date(post.date, &#39;YYYY&#39;)); %&gt;    &lt;% if (tempYear != currentYear){ %&gt;      &lt;% tempYear = currentYear %&gt;      &lt;article&gt;        &lt;h3&gt;&lt;%- currentYear%&gt;&lt;/h3&gt;    &lt;% } %&gt;        &lt;section&gt;          &lt;span class=&quot;point-time point-yellow&quot;&gt;&lt;/span&gt;          &lt;time datetime=&quot;&lt;%- date(post.date, &#39;YYYY-MM&#39;)%&gt;&quot;&gt;            &lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD,&#39;)%&gt;&lt;/span&gt;          &lt;/time&gt;          &lt;aside&gt;            &lt;p class=&quot;things&quot;&gt;&lt;%= post.title%&gt;&lt;/p&gt;             &lt;p class=&quot;brief&quot;&gt;&lt;span class=&quot;text-yellow&quot;&gt;&lt;%= Object.values(post.categories.data[0])[0] %&gt;            &lt;/span&gt;&lt;/p&gt;          &lt;/aside&gt;        &lt;/section&gt;    &lt;% if (!posts.eq(i + 1) || currentYear != parseInt(date(posts.eq(i + 1).date, &#39;YYYY&#39;))){ %&gt;      &lt;/article&gt;    &lt;% } %&gt;  &lt;% }) %&gt;&lt;/div&gt;</code></pre><p>首先在循环外部定义了两个变量teamYear和posts。其中tempYear用来保存临时的年份信息，posts则是保存了按时间排序的所有文章数组。接下来循环posts，第一次循环的时候用currentYear来保存当前这篇文章的创建的年份，此时tempYear肯定和currentYear不等的，所以能进入if语句，将currentYear赋值给tempYear，并生成了article和年份的标题。接下来就是生成文章信息，没啥好说的。最后在用eq(i+1)来获取下一篇文章的信息。顺带一提，eq()这方法也是Model.js中提供的方法。如果没有下一篇了或者下一篇文章的创建年份和这一篇不同，则结束article标签，下一个循环又会再一次进if语句，生成新的年份。反之下一循环还在这一年份，那么此时tempYear肯定和currentYear是相等的，则不会进入if语句，只是在article中增加了一个section来展示文章。（不知道看懂没，我觉得应该能看懂了）</p><h2 id="分类显示不同颜色"><a href="#分类显示不同颜色" class="headerlink" title="分类显示不同颜色"></a>分类显示不同颜色</h2><p>首先我们确定颜色是由text-yellow这个class决定的，只要把每个分类名对应一个颜色类就搞定了。可以使用js来实现，当然也可以用css来实现（中文类名也是可以的哦，当然不支持这样做）。这里我采用取巧的方法，顺带也讲个hexo文档中重要的知识点：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwen53icYdnElhxLWE09tibDulCOaicGvBePq1RdY8gaRmtnQ8OhALYCDHGdf5PkibgmNKIdPxCT36iaSoA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>我们要用它的关键在这里：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwen53icYdnElhxLWE09tibDulyJHsEicjIjJXukg5aXkGLbZvQKTp4ZxsOhcahOKT4UMMsvD74p3qRvA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>因为我们的language: zh-cn，所以在主题languages文件夹中新建zh-cn.yml，然后在里面输入下内容</p><pre><code>color:  技术: blue  生活: green  相册: red  vlog: yellow</code></pre><p>修改archive.ejs如下：</p><pre><code class="html">......&lt;section&gt;  &lt;!-- 取巧方法，只认第一个分类 --&gt;  &lt;% var category = Object.values(post.categories.data[0])[0]%&gt;  &lt;span class=&quot;point-time point-&lt;%= __(&#39;color.&#39; + category)%&gt;&quot;&gt;&lt;/span&gt;  &lt;time datetime=&quot;&lt;%- date(post.date, &#39;YYYY-MM&#39;)%&gt;&quot;&gt;    &lt;span&gt;&lt;%- date(post.date, &#39;MMMM DD,&#39;)%&gt;&lt;/span&gt;  &lt;/time&gt;  &lt;aside&gt;    &lt;p class=&quot;things&quot;&gt;&lt;%= post.title%&gt;&lt;/p&gt;    &lt;p class=&quot;brief&quot;&gt;&lt;span class=&quot;text-&lt;%= __(&#39;color.&#39; + category)%&gt;&quot;&gt;&lt;%= category%&gt;    &lt;/span&gt;&lt;/p&gt;  &lt;/aside&gt;&lt;/section&gt;......</code></pre><p>然后顺带把article.ejs中的返回按钮也给它加上，最终效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwen53icYdnElhxLWE09tibDuldK36WJt35HI4Yv81LzpNHnxEgGIOUHz7J2mqJTibvaaYwic8OkaBM2yQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="首页侧边栏导航"><a href="#首页侧边栏导航" class="headerlink" title="首页侧边栏导航"></a>首页侧边栏导航</h2><p>主题开发到这其实还有很多必要的东西未加上去，比如现在首页还没有一个导航能够到archive.ejs页，手机端适配等很多问题。还有一些小功能，比如赞赏、分享等等。想了一下，现在最紧急的应该就是首页导航了，准备用侧边栏。网上找了个侧边栏代码如下：</p><pre><code class="html">&lt;nav&gt;  &lt;div class=&quot;menu-btn&quot;&gt;    &lt;div class=&quot;line line__1&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__2&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__3&quot;&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;div class=&quot;sub-menu-btn&quot;&gt;    &lt;div class=&quot;line line__1&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__2&quot;&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;ul class=&quot;nav-links&quot;&gt;    &lt;li class=&quot;link&quot;&gt;      &lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;    &lt;/li&gt;    &lt;li class=&quot;link&quot;&gt;      &lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;      &lt;ol&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;designers&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;developers&lt;/a&gt;&lt;/li&gt;      &lt;/ol&gt;    &lt;/li&gt;    &lt;li class=&quot;link&quot;&gt;      &lt;a href=&quot;#&quot;&gt;Work&lt;/a&gt;      &lt;ol&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;web&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;graphic &lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;apps &lt;/a&gt;&lt;/li&gt;      &lt;/ol&gt;    &lt;/li&gt;    &lt;li class=&quot;link&quot;&gt;      &lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;      &lt;ol&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Email&lt;/a&gt;&lt;/li&gt;        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Social&lt;/a&gt;&lt;/li&gt;      &lt;/ol&gt;    &lt;/li&gt;    &lt;li class=&quot;link&quot;&gt;      &lt;a href=&quot;#&quot;&gt;follow me&lt;/a&gt;      &lt;ol&gt;        &lt;li&gt;          &lt;a target=&quot;_blank&quot; href=&quot;https://www.17sucai.com/&quot;&gt;            Twitter &lt;i class=&quot;fab fa-twitter&quot;&gt;&lt;/i&gt;          &lt;/a&gt;        &lt;/li&gt;        &lt;li&gt;          &lt;a target=&quot;_blank&quot; href=&quot;https://www.17sucai.com/&quot;&gt;            Codepen &lt;i class=&quot;fab fa-codepen&quot;&gt;&lt;/i&gt;          &lt;/a&gt;        &lt;/li&gt;      &lt;/ol&gt;    &lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</code></pre><p>包括css和js代码添加在story\source\js\sidebar.js和story\source\css\sidebar.css，而后在header中引入css,footer中引入js，由于篇幅有限，这里就不展示了。这里说一下为啥有些css和js不在header和footer中引入，比如archive.css。因为这个css只有归档页面中有用到，没必要在其他页面中引入它，这也加快了页面加载速度，后其也可以把多个css、js合并压缩成一个，这样会减少请求次数，也优化了页面速度。</p><p>加入后效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwen53icYdnElhxLWE09tibDul1Q1q08KKtMiaPv0bvF98qCvWuqYMsME5jN5BmVLU4l5icDj7GHJwVjXA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注回复story010获取。</p><h2 id="完善侧边栏"><a href="#完善侧边栏" class="headerlink" title="完善侧边栏"></a>完善侧边栏</h2><p>上一篇教程我们已经把侧边栏成功的加入到我们的story主题中了，但是该侧边栏还是写死的数据。所以开始把它和我们的主题目录绑定起来。有用过hexo主题的朋友应该知道在config中一般有个menu配置项，用来配置博客的模板页。今天我们就来实现这一过程。<br>在此之前，有一样东西必须要了解一下（虽然不了解也没事）。那就是config.yml，如果说你学习过其他语言，甚至是开发过一些项目。那么你用的配置文件可能是.json.conf.xml.pro.ini。那么hexo中的.yml又是什么呢？感兴趣的可以学习另一篇文章：<a href="http://mp.weixin.qq.com/s?__biz=MzI2NjE5Nzg4NQ==&amp;mid=2247484098&amp;idx=4&amp;sn=9291661cbddfcb5c4950143814a6d1a7&amp;chksm=ea908cd0dde705c6e0e19f0db2b896353ca66665742869c636eba5f4cfa6b605119b42f6e2a6&amp;scene=21#wechat_redirect" target="_blank" rel="noopener">yaml基本语法及实现Hexo二级导航栏功能</a><br>开始撸代码之前我们要在config中添加sidebar的项：（暂定如下，图标还未考虑好）</p><pre><code>sidebar: # 侧边栏  首页: { path: /, fa: fa }  归档: { path: /, fa: fa }  关于: { path: /, fa: fa }  项目: { path: /, fa: fa, submenus: {     hexo-theme-sakura: { path: /, fa: fa},     hexo-theme-story: { path: /, fa: fa},     hugo-theme-diaspora: { path: /, fa: fa},     hugo-theme-jsimple: { path: /, fa: fa}  } }  友链: { path: /, fa: fa }  FOLLOW ME: { path: /, fa: fa, submenus: {     qq: { path: /, fa: fa},     sina: { path: /, fa: fa},     github: { path: /, fa: fa },    weichat: { path: /, fa: fa},     bilibili: { path: /, fa: fa },  } }</code></pre><p>因为post-list中的代码已经够多，而且侧边栏也不算是post-list，所以我们在_partial下新建一个sidebar.ejs文件，把侧边栏代码放进去。然后修改代码如下：(为啥用for in?因为循环的是对象)</p><pre><code class="html">&lt;nav&gt;  &lt;div class=&quot;menu-btn&quot;&gt;    &lt;div class=&quot;line line__1&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__2&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__3&quot;&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;div class=&quot;sub-menu-btn&quot;&gt;    &lt;div class=&quot;line line__1&quot;&gt;&lt;/div&gt;    &lt;div class=&quot;line line__2&quot;&gt;&lt;/div&gt;  &lt;/div&gt;  &lt;ul class=&quot;nav-links&quot;&gt;    &lt;% var sidebar = theme.sidebar %&gt;    &lt;% for (item in sidebar) {%&gt;      &lt;li class=&quot;link&quot;&gt;        &lt;% if (!sidebar[item].submenus) {%&gt;          &lt;a href=&quot;&lt;%- url_for(sidebar[item].path) %&gt;&quot;&gt;&lt;%- item %&gt;&lt;/a&gt;        &lt;% } else { %&gt;          &lt;a href=&quot;&lt;%- url_for(sidebar[item].path) %&gt;&quot; style=&quot;pointer-events: none;&quot;&gt;&lt;%- item %&gt;&lt;/a&gt;          &lt;ol&gt;            &lt;% for (submenu in sidebar[item].submenus) {%&gt;              &lt;li&gt;&lt;a href=&quot;&lt;%- url_for(sidebar[item].submenus[submenu].path) %&gt;&quot;&gt;&lt;%- submenu %&gt;&lt;/a&gt;&lt;/li&gt;            &lt;% } %&gt;          &lt;/ol&gt;        &lt;% } %&gt;      &lt;/li&gt;    &lt;% } %&gt;  &lt;/ul&gt;&lt;/nav&gt;</code></pre><p>就里讲下pointer-events: none<br>pointer-events 更像是JavaScript，它能够：</p><ul><li>阻止用户的点击动作产生任何效果</li><li>阻止缺省鼠标指针的显示</li><li>阻止CSS里的 hover 和 active 状态的变化触发事件</li><li>阻止JavaScript点击动作触发的事件</li></ul><p>了解更多参考MDN:pointer-events<br>侧边栏效果如下：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwegBEzbL544WYeRUgnRbwq4lBicxfmicxSsh7Tn3PDsicjRBgRkWEWxFW6UkGHs8PPLftRSeIuic17GxA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><h2 id="给侧边栏添加图标"><a href="#给侧边栏添加图标" class="headerlink" title="给侧边栏添加图标"></a>给侧边栏添加图标</h2><p>先在header.ejs中添加fontawesome的css:</p><pre><code>&lt;%- css([&#39;/css/main.css&#39;, &#39;/css/noscript.css&#39;, &#39;/css/sidebar.css&#39;, &#39;/css/fontawesome-all.min.css&#39;]) %&gt;</code></pre><p>接着来到fontawesome官网<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwegBEzbL544WYeRUgnRbwq45KHK1qFds94m7m1ekjTdhw0GO6ic12ayJjv9ttiaWgUIgZKEDupIiaTbg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>点击图标，找到home的class。同理找到其他的图标。<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwegBEzbL544WYeRUgnRbwq4UbTobL7DbXIhQc7VaOTUS5TcfoxOvCdywrAiaMhic0YEUZVOFS3gJH7w/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"><br>修改config如下：（subsmenu就留给你们练手了）</p><pre><code>sidebar: # 侧边栏  首页: { path: /, fa: fa fa-home }  归档: { path: /archives/, fa: fa fa-archive }  关于: { path: /, fa: fa fa-question-circle }  项目: { path: /, fa: fa fa-paper-plane, submenus: {     hexo-theme-sakura: { path: /, fa: fa},     hexo-theme-story: { path: /, fa: fa},     hugo-theme-diaspora: { path: /, fa: fa},     hugo-theme-jsimple: { path: /, fa: fa}  } }  友链: { path: /, fa: fa fa-link }  FOLLOW ME: { path: /, fa: fa fa-heart, submenus: {     qq: { path: /, fa: fa},     sina: { path: /, fa: fa},     github: { path: /, fa: fa },    weichat: { path: /, fa: fa},     bilibili: { path: /, fa: fa }  } }</code></pre><p>然后修改sidebar.ejs代码如下：(加了个i标签哦)</p><pre><code>&lt;% if (!sidebar[item].submenus) {%&gt;  &lt;a href=&quot;&lt;%- url_for(sidebar[item].path) %&gt;&quot;&gt;&lt;i class=&quot;&lt;%= sidebar[item].fa %&gt;&quot;&gt;&lt;/i&gt;&lt;%- item %&gt;&lt;/a&gt;&lt;% } else { %&gt;  &lt;a href=&quot;&lt;%- url_for(sidebar[item].path) %&gt;&quot; style=&quot;pointer-events: none;&quot;&gt;&lt;i class=&quot;&lt;%= sidebar[item].fa %&gt;&quot;&gt;&lt;/i&gt;&lt;%- item %&gt;&lt;/a&gt;</code></pre><p>最终效果如下！：<br><img src="https://mmbiz.qpic.cn/mmbiz_png/7oh1DvJRVwegBEzbL544WYeRUgnRbwq4VdiadLy84CFLwUuBn7SJPHmUgeRdLQ2X8kx4Qm0Eicg1SC3BnrPtrbrg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="img"></p><p>代码同步上传在github仓库和百度云上，关注回复story011获取。</p><font text-align="center">本文完</font><br>由于转载的，故图片不想一个个弄出来了<br>你们自己到作者公众号去看吧<br><br><br><br><br><font color="red" size="18px">文章来源：</font><hr><p><font color="pink" size="6px">|文章链接：</font><a href="https://mp.weixin.qq.com/s/XhTqTpA77is96QKqnVVzwg" target="_blank" rel="noopener">都2020了，带你开发hexo主题</a></p><p><font color="pink" size="6px">|公众号：</font> <a href="https://mp.weixin.qq.com/mp/profile_ext?action=home&amp;__biz=MzI2NjE5Nzg4NQ==&amp;scene=124#wechat_redirect" target="_blank" rel="noopener">Creators创作者</a></p><p><font color="pink" size="6px">|作者：</font>Hojun</p><p><font color="pink" size="6px">|作者博客：</font><a href="https://www.hojun.cn/" target="_blank" rel="noopener">https://www.hojun.cn/</a></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="转载" scheme="https://sakura.wallleap.cn/categories/%E8%BD%AC%E8%BD%BD/"/>
    
      <category term="主题" scheme="https://sakura.wallleap.cn/categories/%E8%BD%AC%E8%BD%BD/%E4%B8%BB%E9%A2%98/"/>
    
    
      <category term="主题" scheme="https://sakura.wallleap.cn/tags/%E4%B8%BB%E9%A2%98/"/>
    
  </entry>
  
  <entry>
    <title>Win10启用其子系统Ubuntu并安装图形界面</title>
    <link href="https://sakura.wallleap.cn/2019/11/07/WLU/"/>
    <id>https://sakura.wallleap.cn/2019/11/07/WLU/</id>
    <published>2019-11-07T02:21:17.000Z</published>
    <updated>2019-11-07T02:28:43.529Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="Win10启用其子系统Ubuntu并安装图形界面"><a href="#Win10启用其子系统Ubuntu并安装图形界面" class="headerlink" title="Win10启用其子系统Ubuntu并安装图形界面"></a>Win10启用其子系统Ubuntu并安装图形界面</h1><h1 id="0-说明"><a href="#0-说明" class="headerlink" title="0.说明"></a>0.说明</h1><p>好像只有16215版本之后的才可以</p><p>鉴于双显卡安装时会卡logo，需要自己修改命令，MacOS+win10+Ubuntu总是会进入紧急模式，而且虚拟机体验非常不好，所以直接启用Win10的子系统，使用起来还是很方便的</p><h2 id="1-启用-“适用于-Linux-的-Windows-子系统”可选功能"><a href="#1-启用-“适用于-Linux-的-Windows-子系统”可选功能" class="headerlink" title="1.启用 “适用于 Linux 的 Windows 子系统”可选功能"></a>1.启用 “适用于 Linux 的 Windows 子系统”可选功能</h2><p>方法一: 设置-更新和安全-开发者选项-勾选开发人员模式，接着打开控制面板-程序-启用或关闭Windows功能-勾选“适用于Linux的Windows子系统”前的复选框</p><p>方法二：搜索Poweshell，选择<code>以管理员身份运行</code><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/wlu/1572956839709.png" alt="1572956839709"></p><p>输入命令</p><pre><code>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux</code></pre><p>接着输入<code>Y</code>回车，重启</p><h2 id="2-下载Linux发布版"><a href="#2-下载Linux发布版" class="headerlink" title="2.下载Linux发布版"></a>2.下载Linux发布版</h2><p>打开Win10自带的Microsoft Store，选择自己需要的版本下载</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/wlu/1572957066606.png" alt="1572957066606"></p><p>单击以下链接会打开每个分发版的 Microsoft Store 页面：</p><ul><li><a href="https://www.microsoft.com/store/apps/9pjn388hp8c9" target="_blank" rel="noopener">Ubuntu 16.04 LTS</a></li><li><a href="https://www.microsoft.com/store/apps/9N9TNGVNDL3Q" target="_blank" rel="noopener">Ubuntu 18.04 LTS</a></li><li><a href="https://www.microsoft.com/store/apps/9n1tb6fpvj8c" target="_blank" rel="noopener">OpenSUSE Leap 15</a></li><li><a href="https://www.microsoft.com/store/apps/9njvjts82tjx" target="_blank" rel="noopener">OpenSUSE Leap 42</a></li><li><a href="https://www.microsoft.com/store/apps/9p32mwbh6cns" target="_blank" rel="noopener">SUSE Linux Enterprise Server 12</a></li><li><a href="https://www.microsoft.com/store/apps/9pmw35d7fnlx" target="_blank" rel="noopener">SUSE Linux Enterprise Server 15</a></li><li><a href="https://www.microsoft.com/store/apps/9PKR34TNCV07" target="_blank" rel="noopener">Kali Linux</a></li><li><a href="https://www.microsoft.com/store/apps/9MSVKQC78PK6" target="_blank" rel="noopener">Debian GNU/Linux</a></li><li><a href="https://www.microsoft.com/store/apps/9n6gdm4k2hnc" target="_blank" rel="noopener">Fedora Remix for WSL</a></li><li><a href="https://www.microsoft.com/store/apps/9NV1GV1PXZ6P" target="_blank" rel="noopener">Pengwin</a></li><li><a href="https://www.microsoft.com/store/apps/9N8LP0X93VCP" target="_blank" rel="noopener">Pengwin Enterprise</a></li><li><a href="https://www.microsoft.com/store/apps/9p804crf0395" target="_blank" rel="noopener">Alpine WSL</a></li></ul><h2 id="3-启动并设置账户"><a href="#3-启动并设置账户" class="headerlink" title="3.启动并设置账户"></a>3.启动并设置账户</h2><p>点击<kbd>win</kbd>键，找到Ubuntu，点击打开</p><p>之后会显示<code>Installing...</code>等待安装完</p><p>之后会要求输入用户名和密码，按照自己的输入即可(ps:输入密码不会显示，输完之后回车即可)</p><h2 id="4-修改软件源-可选-及更新和升级分发版的包"><a href="#4-修改软件源-可选-及更新和升级分发版的包" class="headerlink" title="4.修改软件源(可选)及更新和升级分发版的包"></a>4.修改软件源(可选)及更新和升级分发版的包</h2><p>由于默认官方源服务器在国外，访问速度慢，因此将服务器源改为国内的：</p><p><code>阿里云源</code>: <a href="http://mirrors.aliyun.com/ubuntu/" target="_blank" rel="noopener">http://mirrors.aliyun.com/ubuntu/</a><br><code>清华源</code>: <a href="http://mirrors.tuna.tsinghua.edu.cn/ubuntu/" target="_blank" rel="noopener">http://mirrors.tuna.tsinghua.edu.cn/ubuntu/</a> </p><p>方法一：修改源列表(<code>/etc/apt/sources.list</code>)</p><p>(1)模板：</p><pre><code>deb http://cn.archive.ubuntu.com/ubuntu/ boinc main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ boinc-security main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ boinc-updates main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ boinc-backports main restricted universe multiverse##測試版源deb http://cn.archive.ubuntu.com/ubuntu/ boinc-proposed main restricted universe multiverse# 源碼deb-src http://cn.archive.ubuntu.com/ubuntu/ boinc main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ boinc-security main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ boinc-updates main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ boinc-backports main restricted universe multiverse##測試版源deb-src http://cn.archive.ubuntu.com/ubuntu/ boinc-proposed main restricted universe multiverse# Canonical 合作夥伴和附加deb http://archive.canonical.com/ubuntu/ boinc partnerdeb http://extras.ubuntu.com/ubuntu/ boinc main</code></pre><p>(2)编辑</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/wlu/1572958785969.png" alt="1572958785969"></p><p>所有的源都是这种模式，我们需要改的是红绿部分，红色的为源地址，绿色的为Ubuntu版本代号</p><p>源地址为上面给的两个，直接替换掉就行</p><p>Ubuntu版本代号通过命令查看：</p><pre><code>lsb_release -a</code></pre><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/wlu/1572958997879.png" alt="1572958997879"></p><p>故修改后为</p><pre><code># 阿里云源deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse##測試版源deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse# 源碼deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse##測試版源deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse# 清华大学源deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse##測試版源deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse# 源碼deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiversedeb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiversedeb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiversedeb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse##測試版源deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse</code></pre><p>(3)修改源文件<code>sources.list</code></p><p>修改前我们先做个备份，在终端中执行以下命令：</p><pre><code class="Ubuntu">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup</code></pre><p>然后执行下面的命令打开 sources.list 文件，清空里面的内容<code>dG</code>，把上面我们编辑好的国内的源复制进去，保存后退出<kbd>ESC</kbd>,<code>wq</code>+<kbd>Enter</kbd>。</p><pre><code class="Ubuntu">sudo vi /etc/apt/sources.list</code></pre><p>(4)更新软件列表和升级<br>在终端上执行以下命令更新软件列表，检测出可以更新的软件：</p><pre><code class="Ubuntu">sudo apt-get update</code></pre><p>在终端上执行以下命令进行软件更新：</p><pre><code>sudo apt-get upgrade</code></pre><p>方法二：通过<a href="https://blog.csdn.net/l740450789/article/details/50856596" target="_blank" rel="noopener">命令apt-add-repository</a></p><p>略</p><h2 id="5-安装图形界面"><a href="#5-安装图形界面" class="headerlink" title="5. 安装图形界面"></a>5. 安装图形界面</h2><p>对于Linux来说使用shell命令行完全满足大部分场景的使用，但是某些情况还是需要图形界面，比如查看图片、视频，浏览网页，UI设计等，还是需要图形界面的</p><h3 id="安装必要软件包"><a href="#安装必要软件包" class="headerlink" title="安装必要软件包"></a>安装必要软件包</h3><p>可以通过执行<code>sudo dpkg-reconfigure locales</code> 选择zh-CN.UTF-8将系统切换为中文环境。</p><p>安装桌面、语言包、字体包、输入法等必要软件。</p><p>这里选择的是lxde轻量化桌面，个人比较推荐，当然也可以选择xfce，lxqt等其他桌面。</p><pre><code>sudo apt install lubuntu-core lxde fcitx fcitx-googlepinyinsudo apt install language-pack-gnome-zh-hanssudo apt install fonts-wqy-zenhei</code></pre><h3 id="使用远程桌面软件连接"><a href="#使用远程桌面软件连接" class="headerlink" title="使用远程桌面软件连接"></a>使用远程桌面软件连接</h3><p>受限于Linux子系统实现原理，图形界面无法直接输出到显示器。</p><p>这里选择vnc远程桌面来解决，当然你也可以选择其他远程桌面方案。</p><p>最新版二进制包tigervnc_X86_64<a href="https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz，下载解压到根目录即可使用" target="_blank" rel="noopener">https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz，下载解压到根目录即可使用</a>:</p><pre><code>wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz</code></pre><pre><code>sudo tar -C / -zxvf download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz</code></pre><p>执行<code>vncserver :0</code>打开一个远程桌面端口。:0 表示开启5900端口，:1表示5901端口，依次类推。vncserver详细用法见vncserver -h。</p><p>Win10打开<a href="https://bintray.com/tigervnc/stable/download_file?file_path=vncviewer64-1.9.0.exe" target="_blank" rel="noopener">Windows端vnc客户端</a>，输入IP(可用环回地址)和对于端口号即可进入图形界面。若为第0个端口（即5900）可省略。</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/wlu/1572961279619.png" alt="1572961279619"></p><p>通过客户端我们会发现，进入后为黑屏无图像显示。这是因为lxde桌面没启动。</p><p>第一次使用vnc会在用户家目录下生成 .vnc目录，里面是vnc的配置文件。通过在<code>~/.vnc/xstartup</code> 末行加上 <code>startlxde&amp;</code>。</p><p>通过<code>vncserver -kill :0;vncserver :0</code>重启端口即可进入桌面。</p><p> 安装到此结束，然后就可以愉快地使用了。</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="电脑" scheme="https://sakura.wallleap.cn/categories/%E7%94%B5%E8%84%91/"/>
    
    
      <category term="Win10" scheme="https://sakura.wallleap.cn/tags/Win10/"/>
    
      <category term="Ubuntu" scheme="https://sakura.wallleap.cn/tags/Ubuntu/"/>
    
  </entry>
  
  <entry>
    <title>唐迟阅读方法论</title>
    <link href="https://sakura.wallleap.cn/2019/10/31/English_ReadWay/"/>
    <id>https://sakura.wallleap.cn/2019/10/31/English_ReadWay/</id>
    <published>2019-10-31T13:58:17.000Z</published>
    <updated>2019-10-31T14:49:38.900Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="阅读方法论"><a href="#阅读方法论" class="headerlink" title="阅读方法论"></a>阅读方法论</h1><h2 id="提高效率的步骤"><a href="#提高效率的步骤" class="headerlink" title="提高效率的步骤:"></a>提高效率的步骤:</h2><p><strong>※先题干后文</strong></p><ul><li>出题顺序和行文顺序保持一致 </li><li>带着问题找答案 </li></ul><p><strong>※串联题干</strong>:找题目里被<font color="red">反复重复</font>提及的内容——重中之重(中心) </p><ul><li>考研文章类型:开门见山/铺垫</li><li>通过串联题干避免误入歧途</li><li>找到题干中反复出现的内容 </li></ul><p><strong>※</strong>  <strong>避免选项干扰</strong> </p><h2 id="题型总结"><a href="#题型总结" class="headerlink" title="题型总结:"></a>题型总结:</h2><h3 id="一、中心思想题"><a href="#一、中心思想题" class="headerlink" title="一、中心思想题:"></a>一、中心思想题:</h3><ol><li><p><strong>标志</strong> <code>mainly about</code>/<code>discuss</code>/<code>the best title</code>/<code>the purpose</code></p></li><li><p><strong>方法:</strong> </p></li></ol><p>(1)串线:将各段首末句串联成一个整体，注意转折处(普遍适用)</p><p>(2)中心句:问题开头的提问，对它的回答，是文章中心独句段 </p><p>(3)中心词:文中反复高频出现的词(最直观的方法) </p><ol start="3"><li><strong>注意:</strong> </li></ol><ul><li>时间相反，一切相反(比如过去如何如何，现在如何如何，那么两种不同 时间下的状态一般是相反的) </li><li>少数派原则——中心(作者一般关注的是大多数人所没关注到的内容) </li><li>线性思维(不要过度推理) </li><li>近年真题中的主旨题走了文艺范 </li></ul><h3 id="二、词汇题"><a href="#二、词汇题" class="headerlink" title="二、词汇题:"></a>二、词汇题:</h3><ol><li><p><strong>标志</strong>:<code>“???”(Line,paragragh)most probably means</code></p></li><li><p><strong>方法</strong>:通过定位好的句子，根据逻辑关系找同义词或反义词 </p></li><li><p><strong>干扰选项特征</strong>:字面意思理解<br>(往往要先排除简单词的常用含义)<br>(分号、冒号往往表示“=”，即同义) </p></li><li><p><strong>代词指代</strong>:根据上下文，优先指代主题词，是识别同义表达的捷径 </p></li></ol><h3 id="三、例证题"><a href="#三、例证题" class="headerlink" title="三、例证题:"></a>三、例证题:</h3><ol><li><p><strong>标志</strong>:<code>example</code>/<code>case illustrate demonstrate to show to ______</code> </p></li><li><p>例子本身不重要，重要的是例子所支持的观点。观点一般在例子前，有时也在例子后 </p></li><li><p><strong>干扰选项</strong>:就事论事(只关注例子本身) </p></li><li><p>近年真题，如果掌握例子内容，做题会更加精准(找到共同讨论的话题，重复出现的是重点) </p></li></ol><p><strong>※找作者观点的标志</strong>:</p><ul><li>转折，<code>now</code></li><li>反复提及的点 </li><li><code>I，maintain</code>/<code>hold that</code></li><li>感情色彩特别丰富的词 </li><li>情态动词 <code>should</code> <code>could</code> <code>would</code> <code>must</code> 及其否定形式 </li></ul><p><strong>※</strong> 反复强调的对象也可以是非主干的成分 </p><p><strong>※</strong> “观其大略，不求甚解”，把握大方向，提升解题效率 </p><h3 id="四、细节题"><a href="#四、细节题" class="headerlink" title="四、细节题:"></a>四、细节题:</h3><ol><li><p><strong>标志</strong>:<code>What</code>/<code>how</code>/<code>why</code>/<code>because</code>/<code>because of</code>/<code>in that</code>/<code>since</code>/<code>as</code>/<code>for</code>(等)+<code>具体信息</code></p></li><li><p>定位好的句子是解题的最为重要的依据，有时结合上下句 </p></li><li><p>选择最佳答案——比较(反复强调的是重点，重点是考点，细节服从主旨) </p><p><strong>注意</strong>:例证题和细节题都要定位，但是细节题定位点即为答案，而例证题定位 点并非答案，答案在例子前或例子后 </p></li></ol><h3 id="五、作者态度题"><a href="#五、作者态度题" class="headerlink" title="五、作者态度题:"></a>五、作者态度题:</h3><ol><li><p><strong>标志</strong>:<code>attitude</code>、<code>deem</code>、<code>consider</code>、<code>tone</code> </p></li><li><p><strong>方法</strong>:选项词汇归纳 </p></li></ol><ul><li>正面:<code>positive</code>、<code>optimistic</code>、<code>approval</code>、<code>supportive</code> </li><li>负面:<code>negative</code>、<code>pessimistic</code>、<code>disapproval</code>、<code>critical</code>、<code>doubtful</code>、<code>suspicious</code>、<code>skeptical</code>、<code>questionable</code>、<br><code>objectionable</code>(令人反感的) </li><li>中立:<code>neural</code>、<code>objective</code>、<code>impartial</code>、<code>disinterested</code> </li><li>不感兴趣:<code>uninterested</code>、<code>unconcerned</code>、<code>indifferent</code>(永远不可能成为正确答案) <ul><li><code>confused</code>、<code>puzzled</code>(永远不可能成为正确答案) </li><li><code>Biased</code>、<code>prejudice</code>、<code>contemptuous</code>、<code>subjective</code>(永远不可能成为正确答案) </li></ul></li></ul><ol start="3"><li>当作者的态度没有明确提出时: </li></ol><ul><li>文章的框架 </li><li>Adj、adv  </li><li>转折处 </li><li>情态动词之后(should、must、could(not)) </li></ul><h3 id="六、推理判断题-最好不做推理"><a href="#六、推理判断题-最好不做推理" class="headerlink" title="六、推理判断题:(最好不做推理)"></a>六、推理判断题:(最好不做推理)</h3><ol><li><p>标志:infer，learnfrom，imply，suggest，conclude </p></li><li><p>方法: </p><p>a. 同义改写——细节/主旨/逻辑<br>b. 逻辑取反——推理多在转折处<br>c. 正确答案往往语气缓和:may </p></li></ol><h2 id="其他"><a href="#其他" class="headerlink" title="其他:"></a>其他:</h2><p>※  <strong>词汇量</strong>是关键 </p><p>※  阅读的本质是<strong>逻辑关系</strong>:</p><ul><li>句间</li><li>段间</li><li>题目之间</li><li>句型结构亦可表因果逻辑</li><li>无转折词，优先考虑相同逻辑相同逻辑，优先考虑因果关系 </li></ul><p>※  <strong>阅读重点</strong>: 感情色彩、不同人物(讨论对象)之间的关系 </p><p>※  任何题型都在原文中可以找到依据，找不到依据，往往是方法不恰当 </p><p>※  考研阅读理解的答案不是选出来的，而是<strong>比较</strong>出来的，排除错误选项，根据文章强调的重点选择最佳答案</p><p>※  <strong>反复强调的是重点，重点是考点</strong> </p><p>※  <strong>绝对化用词</strong>: </p><ul><li><p>Only must exclusively never all、最高级 </p></li><li><p>一般不选，但如果原文明确出现了这样的绝对化表述，则答案可以入选 </p></li><li><p>一般含may/some这样语气较为缓和的词的选项入选可能性较高 </p></li></ul><p>想获取更多笔记，请关注本文原作者微博<a href="https://weibo.com/u/2802451751" target="_blank" rel="noopener">@轰焦冻家的控控</a><br>  <font size="0.5" color="#dda">——————————本文转载自微博@轰焦冻家的控控</font></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="笔记" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/"/>
    
      <category term="转载" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/%E8%BD%AC%E8%BD%BD/"/>
    
    
      <category term="考研" scheme="https://sakura.wallleap.cn/tags/%E8%80%83%E7%A0%94/"/>
    
      <category term="英语" scheme="https://sakura.wallleap.cn/tags/%E8%8B%B1%E8%AF%AD/"/>
    
  </entry>
  
  <entry>
    <title>使用eNSP搭建企业网络</title>
    <link href="https://sakura.wallleap.cn/2019/09/30/web-HCL9/"/>
    <id>https://sakura.wallleap.cn/2019/09/30/web-HCL9/</id>
    <published>2019-09-29T23:58:17.000Z</published>
    <updated>2019-11-17T14:05:34.678Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><p>局域网内的具体技术：如利用vlan进行业务隔离；通过stp技术来防止环路，保证冗余链路的正常通信；学会使用VRRP技术来实现负载分担以及防止单点故障；利用OSPF协议使得总部和分布的网络能够正常通信；以及运用ACL和NAT对数据流进行控制和去外网通信。</p><h2 id="实验拓扑图"><a href="#实验拓扑图" class="headerlink" title="实验拓扑图"></a>实验拓扑图</h2><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic1.png" alt="img"> </p><h2 id="实验配置"><a href="#实验配置" class="headerlink" title="实验配置"></a>实验配置</h2><h3 id="1-vlan间路由"><a href="#1-vlan间路由" class="headerlink" title="(1)vlan间路由"></a>(1)vlan间路由</h3><p><strong>接入层交换机LSW4</strong></p><p><strong>创建VLAN</strong></p><p>[LSW4]vlan 10</p><p>[LSW4-vlan10]vlan 20</p><p>[LSW4-vlan20]quit</p><p>配置与主机相连的接口为Access并绑定VLAN</p><p><strong>[LSW4]int e0/0/1</strong></p><p><strong>[LSW4-Ethernet0/0/1]un sh</strong></p><p><strong>Info: Interface Ethernet0/0/1 is not shutdown.</strong></p><p><strong>[LSW4-Ethernet0/0/1]port link-t a</strong></p><p><strong>[LSW4-Ethernet0/0/1]port de vlan 10</strong></p><p><strong>[LSW4-Ethernet0/0/1]int e0/0/2</strong></p><p><strong>[LSW4-Ethernet0/0/2]port link-t a</strong></p><p><strong>[LSW4-Ethernet0/0/2]port de vlan 20</strong></p><p><strong>配置与交换机相连的接口为Trunk并允许所有VLAN通过</strong></p><p><strong>[LSW4-Ethernet0/0/2]int e0/0/3</strong></p><p><strong>[LSW4-Ethernet0/0/3]port link-t t</strong></p><p><strong>[LSW4-Ethernet0/0/3]port t allow vlan all</strong></p><p><strong>[LSW4-Ethernet0/0/3]int e0/0/4</strong></p><p><strong>[LSW4-Ethernet0/0/4]port link-t t</strong></p><p><strong>[LSW4-Ethernet0/0/4]port t allow vlan all</strong></p><p><strong>[LSW4-Ethernet0/0/4]quit</strong></p><p><strong>l</strong> <strong>接入层交换机LSW5</strong></p><p><strong>与LSW4类似，创建VLAN，设置接口即可</strong></p><p><strong>[LSW5]vlan 30</strong></p><p><strong>[LSW5-vlan30]vlan 40</strong></p><p><strong>[LSW5-vlan40]quit</strong></p><p><strong>[LSW5]int e0/0/1</strong></p><p><strong>[LSW5-Ethernet0/0/1]port link-t a</strong></p><p><strong>[LSW5-Ethernet0/0/1]port de vlan 30</strong></p><p><strong>[LSW5-Ethernet0/0/1]int e0/0/2</strong></p><p><strong>[LSW5-Ethernet0/0/2]port link-t a</strong></p><p><strong>[LSW5-Ethernet0/0/2]port de vlan 40</strong></p><p><strong>[LSW5-Ethernet0/0/2]int e0/0/3</strong></p><p><strong>[LSW5-Ethernet0/0/3]port link-t t</strong></p><p><strong>[LSW5-Ethernet0/0/3]port t allow vlan all</strong></p><p><strong>[LSW5-Ethernet0/0/3]int e0/0/4</strong></p><p><strong>[LSW5-Ethernet0/0/4]port link-t t</strong></p><p><strong>[LSW5-Ethernet0/0/4]port t allow vlan all</strong></p><p><strong>[LSW5-Ethernet0/0/4]quit</strong></p><p><strong>核心层交换机LSW1</strong></p><p><strong>创建VLAN</strong></p><p><strong>[LSW1]vlan 10</strong></p><p><strong>[LSW1-vlan10]vlan 20</strong></p><p><strong>[LSW1-vlan20]vlan 30</strong></p><p><strong>[LSW1-vlan30]vlan 40</strong></p><p><strong>[LSW1-vlan40]vlan 50</strong></p><p><strong>[LSW1-vlan50]quit</strong></p><p><strong>与交换机相连接口设为Trunk并允许所有VLAN通过</strong></p><p><strong>[LSW1]int g0/0/1</strong></p><p><strong>[LSW1-GigabitEthernet0/0/1]port link-t t</strong></p><p><strong>[LSW1-GigabitEthernet0/0/1]port t allow vlan all</strong></p><p><strong>[LSW1-GigabitEthernet0/0/1]int g0/0/3</strong></p><p><strong>[LSW1-GigabitEthernet0/0/3]port link-t t</strong></p><p><strong>[LSW1-GigabitEthernet0/0/3]port t allow vlan all</strong></p><p><strong>[LSW1-GigabitEthernet0/0/3]int g0/0/2</strong></p><p><strong>[LSW1-GigabitEthernet0/0/2]port link-t t</strong></p><p><strong>[LSW1-GigabitEthernet0/0/2]port t allow vlan all</strong></p><p><strong>服务器接入VLAN50，将将与服务器相连的接口设为Access口并绑定VLAN50</strong></p><p><strong>[LSW1-GigabitEthernet0/0/2]int g0/0/5</strong></p><p><strong>[LSW1-GigabitEthernet0/0/5]port link-t a</strong></p><p><strong>[LSW1-GigabitEthernet0/0/5]port de vlan 50</strong></p><p><strong>[LSW1-GigabitEthernet0/0/5]quit</strong></p><p><strong>给连接路由器的接口绑定VLAN*60，方便配置地址</strong></p><p><strong>[LSW1]vlan 60</strong></p><p><strong>[LSW1-vlan60]int g0/0/4</strong></p><p><strong>[LSW1-GigabitEthernet0/0/4]port link-t a</strong></p><p><strong>[LSW1-GigabitEthernet0/0/4]port de vlan 60</strong></p><p><strong>[LSW1-GigabitEthernet0/0/4]quit</strong></p><p>　<strong>给VLAN分配IP地址（配置真实网关）</strong></p><p><strong>[LSW1]int vlan 10</strong></p><p><strong>[LSW1-Vlanif10]ip add 192.168.10.1 24</strong></p><p><strong>[LSW1-Vlanif10]int vlan 20</strong></p><p><strong>[LSW1-Vlanif20]ip add 192.168.20.1 24</strong></p><p><strong>[LSW1-Vlanif20]int vlan 30</strong></p><p><strong>[LSW1-Vlanif30]ip add 192.168.30.1 24</strong></p><p><strong>[LSW1-Vlanif30]int vlan 40</strong></p><p><strong>[LSW1-Vlanif40]ip add 192.168.40.1 24</strong></p><p><strong>[LSW1-Vlanif40]int vlan 50</strong></p><p><strong>[LSW1-Vlanif50]ip add 192.168.50.1 24</strong></p><p><strong>[LSW1-Vlanif50]int vlan 60</strong></p><p><strong>[LSW1-Vlanif60]ip add 192.168.60.1 24</strong></p><p><strong>[LSW1-Vlanif60]quit</strong></p><p><strong>l</strong> <strong>核心层交换机LSW２</strong></p><p><strong>与LSW１类似，创建VLAN、配置好接口、设置真实网关（与S１地址不同）</strong></p><p><strong>[LSW2]vlan 10</strong></p><p><strong>[LSW2-vlan10]vlan 20</strong></p><p><strong>[LSW2-vlan20]vlan 30</strong></p><p><strong>[LSW2-vlan30]vlan 40</strong></p><p><strong>[LSW2-vlan40]quit</strong></p><p><strong>[LSW2]int g0/0/1</strong></p><p><strong>[LSW2-GigabitEthernet0/0/1]port link-t t</strong></p><p><strong>[LSW2-GigabitEthernet0/0/1]port t allow vlan all</strong></p><p><strong>[LSW2-GigabitEthernet0/0/1]int g0/0/2</strong></p><p><strong>[LSW2-GigabitEthernet0/0/2]port link-t t</strong></p><p><strong>[LSW2-GigabitEthernet0/0/2]port t allow vlan all</strong></p><p><strong>[LSW2-GigabitEthernet0/0/2]int g0/0/3</strong></p><p><strong>[LSW2-GigabitEthernet0/0/3]port link-t t</strong></p><p><strong>[LSW2-GigabitEthernet0/0/3]port t allow vlan all</strong></p><p><strong>[LSW2-GigabitEthernet0/0/3]quit</strong></p><p><strong>[LSW2]vlan 70</strong></p><p><strong>[LSW2-vlan70]int g0/0/4</strong></p><p><strong>[LSW2-GigabitEthernet0/0/4]port link-t a</strong></p><p><strong>[LSW2-GigabitEthernet0/0/4]port de vlan 70</strong></p><p><strong>[LSW2-GigabitEthernet0/0/4]quit</strong></p><p><strong>[LSW2]int vlan 10</strong></p><p><strong>[LSW2-Vlanif10]ip add 192.168.10.2 24</strong></p><p><strong>[LSW2-Vlanif10]int vlan 20</strong></p><p><strong>[LSW2-Vlanif20]ip add 192.168.20.2 24</strong></p><p><strong>[LSW2-Vlanif20]int vlan 30</strong></p><p><strong>[LSW2-Vlanif30]ip add 192.168.30.2 24</strong></p><p><strong>[LSW2-Vlanif30]int vlan 40</strong></p><p><strong>[LSW2-Vlanif40]ip add 192.168.40.2 24</strong></p><p><strong>[LSW2-Vlanif40]int vlan 70</strong></p><p><strong>[LSW2-Vlanif70]ip add 192.168.70.2 24</strong></p><p><strong>[LSW2-Vlanif70]quit</strong></p><h3 id="2-DHCP的搭建"><a href="#2-DHCP的搭建" class="headerlink" title="(2)DHCP的搭建"></a>(2)DHCP的搭建</h3><p><strong>l</strong> <strong>客户端开启DHCP</strong></p><p><strong>l</strong> <strong>交换机LSW１和LSW２上配置DHCP服务</strong></p><p><strong>开启DHCP服务</strong></p><p><strong>[SW1]dhcp en</strong></p><p><strong>Info: The operation may take a few seconds. Please wait for a moment.done.</strong></p><p><strong>创建地址池vlan10、vlan20、vlan30、vlan40，其中＄代表１~４，网关使用之后配置的虚拟网关</strong></p><p><strong>[LSW1]ip pool vlan＄0</strong></p><p><strong>Info:It’s successful to create an IP address pool.</strong></p><p><strong>[LSW1-ip-pool-vlan$0]gateway-list 192.168.10.254</strong></p><p><strong>[LSW1-ip-pool-vlan$0]network 192.168.＄0.0 mask 255.255.255.0</strong></p><p><strong>[LSW1-ip-pool-vlan$0]quit</strong></p><p><strong>VLAN绑定地址池</strong></p><p><strong>[LSW1]int vlan</strong> <strong>＄0</strong></p><p><strong>[LSW1-Vlanif$0]dhcp select global</strong> </p><p><strong>[LSW1-Vlanif$0]quit</strong></p><p><strong>LSW１排除地址</strong></p><p><strong>[LSW1-ip-pool-vlan$0]excluded-ip-address 192.168.＄0.1 192.168.＄0.127</strong></p><p><strong>LSW２排除地址</strong></p><p><strong>[LSW2-ip-pool-vlan$0]ex 192.168.＄0.128 192.168.＄0.253</strong></p><h3 id="3-STP-VRRP的配置"><a href="#3-STP-VRRP的配置" class="headerlink" title="(3) STP+VRRP的配置"></a>(3) STP+VRRP的配置</h3><p><strong>l</strong> <strong>汇聚层交换机LSW４、LSW５只需要开启STP即可</strong></p><p>[LSW4]stp mode stp</p><p>Info: This operation may take a few seconds. Please wait for a moment…done.</p><p>[LSW5]stp mode stp</p><p>Info: This operation may take a few seconds. Please wait for a moment…done.</p><p><strong>l</strong> <strong>核心层LSW１配置</strong></p><p>开启STP</p><p>[LSW1]stp mode stp</p><p>Info: This operation may take a few seconds. Please wait for a moment…done.</p><p>设置LSW1为根桥</p><p>[LSW1]stp priority 0</p><p>配置VRRP，LSW1是VLAN10、VLAN20的Master，当上层接口错误时，自动降低优先级，让LSW2成为Master</p><p>[LSW1]int vlan 10</p><p>[LSW1-Vlanif10]vrrp vrid 10 vi 192.168.10.254</p><p>[LSW1-Vlanif10]vrrp vrid 10 prio 120</p><p>[LSW1-Vlanif10]vrrp vrid 10 track int g0/0/4 reduce 30</p><p>[LSW1-Vlanif10]int vlan 20</p><p>[LSW1-Vlanif20]vrrp vrid 20 vi 192.168.20.254</p><p>[LSW1-Vlanif20]vrrp vrid 20 prio 120</p><p>[LSW1-Vlanif20]vrrp vrid 20 track int g0/0/4 re 30</p><p>[LSW1-Vlanif20]int vlan 30</p><p>[LSW1-Vlanif30]vrrp vrid 30 vi 192.168.30.254</p><p>[LSW1-Vlanif30]int vlan 40</p><p>[LSW1-Vlanif40]vrrp vrid 40 vi 192.168.40.254</p><p>[LSW1-Vlanif40]quit</p><p><strong>l</strong> <strong>核心层LSW２配置</strong></p><p>开启STP，并将优先级设为4096</p><p>[LSW2]stp mode stp</p><p>Info: This operation may take a few seconds. Please wait for a moment…done.</p><p>[LSW2]stp prio 4096</p><p>配置VRRP，LSW2是VLAN30、VLAN40的Master，当上层接口错误时，自动降低优先级，让LSW1成为Master</p><p>[LSW2]int vlan 10</p><p>[LSW2-Vlanif10]vrrp vrid 10 vi 192.168.10.254</p><p>[LSW2-Vlanif10]int vlan 20</p><p>[LSW2-Vlanif20]vrrp vrid 20 vi 192.168.20.254</p><p>[LSW2-Vlanif20]int vlan 30</p><p>[LSW2-Vlanif30]vrrp vrid 30 vi 192.168.30.254</p><p>[LSW2-Vlanif30]vrrp vrid 30 prio 120</p><p>[LSW2-Vlanif30]vrrp vrid 30 track int g0/0/4 re 30</p><p>[LSW2-Vlanif30]int vlan 40</p><p>[LSW2-Vlanif40]vrrp vrid 40 vi 192.168.40.254</p><p>[LSW2-Vlanif40]vrrp vrid 40 prio 120</p><p>[LSW2-Vlanif40]vrrp vrid 40 track int g0/0/4 re 30</p><p>[LSW2-Vlanif40]quit</p><h3 id="4-OSPF的搭建"><a href="#4-OSPF的搭建" class="headerlink" title="(4)OSPF的搭建"></a>(4)OSPF的搭建</h3><p><strong>l</strong> <strong>LSW１OSPF配置</strong></p><p><strong>查看接口IP</strong></p><p><strong>[LSW1]dis ip int br</strong></p><p><strong>Interface                         IP Address/Mask      Physical   Protocol</strong>  </p><p><strong>MEth0/0/1                         unassigned           down       down</strong>      </p><p><strong>NULL0                             unassigned           up         up(s)</strong>     </p><p><strong>Vlanif1                           unassigned           up         down</strong>      </p><p><strong>Vlanif10                          192.168.10.1/24      up         up</strong>        </p><p><strong>Vlanif20                          192.168.20.1/24      up         up</strong>        </p><p><strong>Vlanif30                          192.168.30.1/24      up         up</strong>        </p><p><strong>Vlanif40                          192.168.40.1/24      up         up</strong>        </p><p><strong>Vlanif50                          192.168.50.1/24      up         up</strong>        </p><p><strong>Vlanif60                          192.168.60.1/24      up         up</strong>        </p><p><strong>根据所有IP宣告相应网段</strong></p><p><strong>[LSW1]ospf 1</strong></p><p><strong>[LSW1-ospf-1]area 0.0.0.0</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.50.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]net 192.168.60.0 0.0.0.255</strong></p><p><strong>[LSW1-ospf-1-area-0.0.0.0]quit</strong></p><p><strong>[LSW1-ospf-1]qu</strong></p><p><strong>l</strong> <strong>LSW２OSPF配置</strong></p><p><strong>与LSW1类似</strong></p><p><strong>[LSW2]dis ip int br</strong></p><p><strong>Interface                         IP Address/Mask      Physical   Protocol</strong>  </p><p><strong>MEth0/0/1                         unassigned           down       down</strong>      </p><p><strong>NULL0                             unassigned           up         up(s)</strong>     </p><p><strong>Vlanif1                           unassigned           up         down</strong>      </p><p><strong>Vlanif10                          192.168.10.2/24      up         up</strong>        </p><p><strong>Vlanif20                          192.168.20.2/24      up         up</strong>        </p><p><strong>Vlanif30                          192.168.30.2/24      up         up</strong>        </p><p><strong>Vlanif40                          192.168.40.2/24      up         up</strong>        </p><p><strong>Vlanif70                          192.168.70.2/24      up         up</strong>        </p><p><strong>[LSW2]ospf 1</strong></p><p><strong>[LSW2-ospf-1]area 0.0.0.0</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255</strong></p><p><strong>[LSW2-ospf-1-area-0.0.0.0]quit</strong></p><p><strong>[LSW2-ospf-1]quit</strong></p><h3 id="5-ACL-NAT"><a href="#5-ACL-NAT" class="headerlink" title="(5)ACL+NAT"></a>(5)ACL+NAT</h3><p><strong>l</strong> <strong>AR１上ACL+NAT配置</strong></p><p><strong>Easy IP：</strong></p><p><strong>配置基本ACL并添加规则，允许VLAN10、VLAN30、VLAN50访问外网，VLAN20、40不能访问</strong></p><p><strong>[AR1]acl number 2000</strong></p><p><strong>[AR1-acl-basic-2000]rule 0 per source 192.168.10.0 0.0.0.255</strong></p><p><strong>[AR1-acl-basic-2000]rule 5 per source 192.168.30.0 0.0.0.255</strong></p><p><strong>[AR1-acl-basic-2000]rule 10 per source 192.168.50.0 0.0.0.255</strong></p><p><strong>[AR1-acl-basic-2000]quit</strong></p><p><strong>绑定规则到外网端口</strong></p><p><strong>[AR1]int g0/0/2</strong></p><p><strong>[AR1-GigabitEthernet0/0/2]nat outbound 2000</strong></p><p><strong>静态NAT，将服务器内网地址转为一个专门的公有IP</strong></p><p><strong>[AR1-GigabitEthernet0/0/2]nat static global 200.200.200.10 inside 192.168.50.253</strong></p><p><strong>[AR1-GigabitEthernet0/0/2]quit</strong></p><h3 id="6-路由器OSPF协议的配置"><a href="#6-路由器OSPF协议的配置" class="headerlink" title="(6)路由器OSPF协议的配置"></a>(6)路由器OSPF协议的配置</h3><p><strong>l</strong> <strong>AR１OSPF配置</strong></p><p><strong>配置接口IP</strong></p><p><strong>[AR1]int g0/0/0</strong></p><p><strong>[AR1-GigabitEthernet0/0/0]ip add 192.168.60.100 24</strong></p><p><strong>Sep 26 2019 09:54:53-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP</strong></p><p> <strong>on the interface GigabitEthernet0/0/0 has entered the UP state.</strong> </p><p><strong>[AR1-GigabitEthernet0/0/0]int g0/0/1</strong></p><p><strong>[AR1-GigabitEthernet0/0/1]ip add 192.168.70.100 24</strong></p><p><strong>Sep 26 2019 09:55:16-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP</strong></p><p> <strong>on the interface GigabitEthernet0/0/1 has entered the UP state.</strong> </p><p><strong>[AR1-GigabitEthernet0/0/1]int g0/0/2</strong></p><p><strong>[AR1-GigabitEthernet0/0/2]ip add 200.200.200.1 24</strong></p><p><strong>Sep 26 2019 09:56:09-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP</strong></p><p> <strong>on the interface GigabitEthernet0/0/2 has entered the UP state.</strong> </p><p><strong>[AR1-GigabitEthernet0/0/2]quit</strong></p><p><strong>查看接口地址</strong></p><p><strong>[AR1]dis ip int br</strong></p><p><strong>Interface                         IP Address/Mask      Physical   Protocol</strong>  </p><p><strong>GigabitEthernet0/0/0              192.168.60.100/24    up         up</strong>        </p><p><strong>GigabitEthernet0/0/1              192.168.70.100/24    up         up</strong>        </p><p><strong>GigabitEthernet0/0/2              200.200.200.1/24     up         up</strong>        </p><p><strong>NULL0                             unassigned           up         up(s)</strong>     </p><p><strong>宣告地址段</strong></p><p><strong>[AR1]ospf 1</strong></p><p><strong>[AR1-ospf-1]area 0.0.0.0</strong></p><p><strong>[AR1-ospf-1-area-0.0.0.0]net 192.168.60.0 0.0.0.255</strong></p><p><strong>[AR1-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255</strong></p><p><strong>[AR1-ospf-1-area-0.0.0.0]net 200.200.200.0 0.0.0.255</strong></p><p><strong>[AR1-ospf-1-area-0.0.0.0]quit</strong></p><p><strong>[AR1-ospf-1]quit</strong></p><p><strong>配置到外网的默认路由，并加入到OSPF中</strong></p><p><strong>[AR1]ip route-static 0.0.0.0 0.0.0.0 200.200.200.100</strong></p><p><strong>[AR1]ospf 1</strong></p><p><strong>[AR1-ospf-1]default-route-advertise</strong> </p><p><strong>[AR1-ospf-1]quit</strong></p><h3 id="7-路由器AR２的配置"><a href="#7-路由器AR２的配置" class="headerlink" title="(7)路由器ＡＲ２的配置"></a>(7)路由器ＡＲ２的配置</h3><p><strong>[AR2]int g0/0/0</strong></p><p><strong>[AR2-GigabitEthernet0/0/0]ip add 200.200.200.100 24</strong></p><p><strong>[AR2-GigabitEthernet0/0/0]int g0/0/1</strong></p><p><strong>[AR2-GigabitEthernet0/0/1]ip add 200.200.201.1 24</strong></p><p><strong>[AR2-GigabitEthernet0/0/1]quit</strong></p><h2 id="结果测试"><a href="#结果测试" class="headerlink" title="结果测试"></a>结果测试</h2><h3 id="1、内网电脑之间进行通信："><a href="#1、内网电脑之间进行通信：" class="headerlink" title="1、内网电脑之间进行通信："></a>1、内网电脑之间进行通信：</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic3.png" alt="img"> </p><p>PC1能够ping通其他四个VLAN内的主机</p><h3 id="2、内网主机动态获取IP地址："><a href="#2、内网主机动态获取IP地址：" class="headerlink" title="2、内网主机动态获取IP地址："></a>2、内网主机动态获取IP地址：</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic2.png" alt="img"> </p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic4.png" alt="img"> </p><p>PC配置DHCP能够自动获取IP</p><h3 id="3、内网主机访问外网："><a href="#3、内网主机访问外网：" class="headerlink" title="3、内网主机访问外网："></a>3、内网主机访问外网：</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic5.png" alt="img"> </p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic6.png" alt="img"> </p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL9/pic7.png" alt="img"> </p><p>PC１、PC３和Server1能够ping通外网的主机，PC2和PC4ping通</p><hr><p> <strong>文章汇总：</strong></p><p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><br><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><br><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><br><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><br><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><br><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><br><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><br><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><br><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><br><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><br><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="eNSP" scheme="https://sakura.wallleap.cn/tags/eNSP/"/>
    
      <category term="企业网" scheme="https://sakura.wallleap.cn/tags/%E4%BC%81%E4%B8%9A%E7%BD%91/"/>
    
  </entry>
  
  <entry>
    <title>ACL+NAT配置</title>
    <link href="https://sakura.wallleap.cn/2019/09/27/web-HCL8/"/>
    <id>https://sakura.wallleap.cn/2019/09/27/web-HCL8/</id>
    <published>2019-09-26T23:58:17.000Z</published>
    <updated>2019-10-24T04:49:59.305Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="实验目的"><a href="#实验目的" class="headerlink" title="实验目的"></a>实验目的</h2><p>让VLAN10、30内的主机能够访问外网，Server1拥有一个公网IP，以便外网主机能够直接访问Server1</p><p>拓扑：</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/pic1.png" alt=""></p><h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><h3 id="PC"><a href="#PC" class="headerlink" title="PC"></a>PC</h3><p>开启DHCP，点应用<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/pic2.png" alt=""></p><h3 id="Server1"><a href="#Server1" class="headerlink" title="Server1"></a>Server1</h3><p>配置静态私网IP，方便转换公网<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/pic3.png" alt=""></p><h3 id="S2："><a href="#S2：" class="headerlink" title="S2："></a>S2：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LSW2[LSW2]vlan 10[LSW2-vlan10]vlan 20[LSW2-vlan20]quit[LSW2]int e0/0/1[LSW2-Ethernet0/0/1]port link-t t[LSW2-Ethernet0/0/1]port t allow vlan all[LSW2-Ethernet0/0/1]int e0/0/2[LSW2-Ethernet0/0/2]port link-t a[LSW2-Ethernet0/0/2]port de vlan 10[LSW2-Ethernet0/0/2]int e0/0/3[LSW2-Ethernet0/0/3]port link-t a[LSW2-Ethernet0/0/3]port de vlan 20[LSW2-Ethernet0/0/3]quit[LSW2]qu&lt;LSW2&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="S3："><a href="#S3：" class="headerlink" title="S3："></a>S3：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS3[LWS3]vlan 30[LWS3-vlan30]vlan 40[LWS3-vlan40]quit[LWS3]int e0/0/2[LWS3-Ethernet0/0/2]port link-t a[LWS3-Ethernet0/0/2]port de vlan 30[LWS3-Ethernet0/0/2]int e0/0/3[LWS3-Ethernet0/0/3]port link-t a[LWS3-Ethernet0/0/3]port de vlan 40[LWS3-Ethernet0/0/3]int e0/0/1[LWS3-Ethernet0/0/1]port link-t t[LWS3-Ethernet0/0/1]port t allow vlan all[LWS3-Ethernet0/0/1]quit[LWS3]quit&lt;LWS3&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="S1"><a href="#S1" class="headerlink" title="S1"></a>S1</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS1[LWS1]vlan 10[LWS1-vlan10]vlan 20[LWS1-vlan20]vlan 30[LWS1-vlan30]vlan 40[LWS1-vlan40]vlan 50[LWS1-vlan50]vlan 60[LWS1-vlan60]quit[LWS1]int g0/0/2[LWS1-GigabitEthernet0/0/2]port link-t [LWS1-port-group-link-t]quit[LWS1]int g0/0/2[LWS1-GigabitEthernet0/0/2]port link-t t[LWS1-GigabitEthernet0/0/2]port t allow vlan all[LWS1-GigabitEthernet0/0/2]int g0/0/3[LWS1-GigabitEthernet0/0/3]port link-t t[LWS1-GigabitEthernet0/0/3]port t allow vlan all[LWS1-GigabitEthernet0/0/3]int g0/0/4[LWS1-GigabitEthernet0/0/4]port link-t a [LWS1-GigabitEthernet0/0/4]port de vlan 50[LWS1-GigabitEthernet0/0/4]int g0/0/1[LWS1-GigabitEthernet0/0/1]port link-t a [LWS1-GigabitEthernet0/0/1]port de vlan 60[LWS1-GigabitEthernet0/0/1]quit[LWS1]dhcp enInfo: The operation may take a few seconds. Please wait for a moment.done.[LWS1]ip pool vlan10Info:It&#39;s successful to create an IP address pool.[LWS1-ip-pool-vlan10]gateway-list 192.168.10.1[LWS1-ip-pool-vlan10]net 192.168.10.0 mask 255.255.255.0[LWS1-ip-pool-vlan10]qu[LWS1]ip pool vlan20Info:It&#39;s successful to create an IP address pool.[LWS1-ip-pool-vlan20]gateway-list 192.168.20.1[LWS1-ip-pool-vlan20]net 192.168.20.0 mask 255.255.255.0[LWS1-ip-pool-vlan20]qu[LWS1]ip pool vlan30Info:It&#39;s successful to create an IP address pool.[LWS1-ip-pool-vlan30]gateway-list 192.168.30.1[LWS1-ip-pool-vlan30]net 192.168.30.0 mask 255.255.255.0[LWS1-ip-pool-vlan30]qu[LWS1]ip pool vlan40Info:It&#39;s successful to create an IP address pool.[LWS1-ip-pool-vlan40]gateway-list 192.168.40.1[LWS1-ip-pool-vlan40]net 192.168.40.0 mask 255.255.255.0[LWS1-ip-pool-vlan40]quit[LWS1]int vlan 10[LWS1-Vlanif10]ip add 192.168.10.1 24[LWS1-Vlanif10]dhcp select global[LWS1-Vlanif10]int vlan 20[LWS1-Vlanif20]ip add 192.168.20.1 24[LWS1-Vlanif20]dhcp select global[LWS1-Vlanif20]int vlan 30[LWS1-Vlanif30]ip add 192.168.30.1 24[LWS1-Vlanif30]dhcp select global[LWS1-Vlanif30]int vlan 40[LWS1-Vlanif40]ip add 192.168.40.1 24[LWS1-Vlanif40]dhcp select global[LWS1-Vlanif40]quit[LWS1]int vlan 50[LWS1-Vlanif50]ip add 192.168.50.1 24[LWS1-Vlanif50]in vlan 60[LWS1-Vlanif60]ip add 192.168.60.1 24[LWS1-Vlanif60]quit[LWS1]qu&lt;LWS1&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.[LWS1]ip route-static 0.0.0.0 0.0.0.0 192.168.60.100</code></pre><h3 id="R2："><a href="#R2：" class="headerlink" title="R2："></a>R2：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR2[LWR2]int g0/0/0[LWR2-GigabitEthernet0/0/0]ip add 200.200.200.100 24 [LWR2-GigabitEthernet0/0/0]int g0/0/1[LWR2-GigabitEthernet0/0/1]ip add 200.200.201.1 24[LWR2-GigabitEthernet0/0/1]quit[LWR2]quit&lt;LWR2&gt;save  The current configuration will be written to the device.   Are you sure to continue? (y/n)[n]:y  It will take several minutes to save configuration file, please wait.......  Configuration file had been saved successfully  Note: The configuration file will take effect after being activatedR1：&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR1[LWR1]int g0/0/0[LWR1-GigabitEthernet0/0/0]un shInfo: Interface GigabitEthernet0/0/0 is not shutdown.[LWR1-GigabitEthernet0/0/0]ip add 192.168.60.100 24[LWR1-GigabitEthernet0/0/0]int g0/0/1[LWR1-GigabitEthernet0/0/1]ip add 200.200.200.1 24[LWR1-GigabitEthernet0/0/1]quit[LWR1]ip route-static 192.168.0.0 255.255.0.0 192.168.60.1[LWR1]ip route-static 200.200.0.0 255.255.0.0 200.200.200.100[LWR1]acl number 2000[LWR1-acl-basic-2000]rule 0 per source 192.168.10.0 0.0.0.255 [LWR1-acl-basic-2000]rule 5 per source 192.168.30.0 0.0.0.255[LWR1-acl-basic-2000]rule 10 per source 192.168.50.0 0.0.0.255[LWR1-acl-basic-2000]quit[LWR1]int g0/0/1[LWR1-GigabitEthernet0/0/1]nat outbound 2000[LWR1-GigabitEthernet0/0/1]nat static global 200.200.200.10 inside 192.168.50.254[LWR1-GigabitEthernet0/0/1]quit[LWR1]quit&lt;LWR1&gt;save  The current configuration will be written to the device.   Are you sure to continue? (y/n)[n]:y  It will take several minutes to save configuration file, please wait..............  Configuration file had been saved successfully  Note: The configuration file will take effect after being activated</code></pre><p>测试<br>PC1、PC2、服务器分别pingPC5<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/PC1.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/PC2.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL8/Server.png" alt=""></p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="eNSP" scheme="https://sakura.wallleap.cn/tags/eNSP/"/>
    
      <category term="ACL" scheme="https://sakura.wallleap.cn/tags/ACL/"/>
    
      <category term="NAT" scheme="https://sakura.wallleap.cn/tags/NAT/"/>
    
  </entry>
  
  <entry>
    <title>OSPF配置</title>
    <link href="https://sakura.wallleap.cn/2019/09/27/web-HCL7/"/>
    <id>https://sakura.wallleap.cn/2019/09/27/web-HCL7/</id>
    <published>2019-09-26T23:58:04.000Z</published>
    <updated>2019-10-24T04:49:59.305Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="■实验目的"><a href="#■实验目的" class="headerlink" title="■实验目的"></a>■实验目的</h2><p>与上一个实验差不多，将RIP换成OSPF即可</p><p>拓扑如下：<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL7/pic1.png" alt=""></p><h2 id="■配置"><a href="#■配置" class="headerlink" title="■配置"></a>■配置</h2><h3 id="▲S4："><a href="#▲S4：" class="headerlink" title="▲S4："></a>▲S4：</h3><blockquote><p>去除提示信息，修改交换机名称</p></blockquote><pre><code>&lt;Huawei&gt;sys Enter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS4</code></pre><blockquote><p>创建VLAN</p></blockquote><pre><code>[LWS4]vlan 10[LWS4-vlan10]vlan 20[LWS4-vlan20]quit</code></pre><blockquote><p>配置接口</p></blockquote><pre><code>[LWS4]int e0/0/3[LWS4-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS4-Ethernet0/0/3]port link-t a[LWS4-Ethernet0/0/3]port de vlan 10[LWS4-Ethernet0/0/3]int e0/0/4[LWS4-Ethernet0/0/4]un shInfo: Interface Ethernet0/0/4 is not shutdown.[LWS4-Ethernet0/0/4]port link-t a[LWS4-Ethernet0/0/4]port de vlan 20[LWS4-Ethernet0/0/4]int e0/0/1[LWS4-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS4-Ethernet0/0/1]port link-t t[LWS4-Ethernet0/0/1]port t allow vlan all[LWS4-Ethernet0/0/1]int e0/0/2[LWS4-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS4-Ethernet0/0/2]port link-t t[LWS4-Ethernet0/0/2]port t allow vlan all[LWS4-Ethernet0/0/2]quit</code></pre><blockquote><p>启动stp并保存配置</p></blockquote><pre><code>[LWS4]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS4]quit&lt;LWS4&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="▲S5："><a href="#▲S5：" class="headerlink" title="▲S5："></a>▲S5：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS5[LWS5]vlan 30[LWS5-vlan30]vlan 40[LWS5-vlan40]quit[LWS5]int e0/0/3[LWS5-Ethernet0/0/3]un shuInfo: Interface Ethernet0/0/3 is not shutdown.[LWS5-Ethernet0/0/3]port link-t a[LWS5-Ethernet0/0/3]port de vlan 30[LWS5-Ethernet0/0/3]int e0/0/4[LWS5-Ethernet0/0/4]un shInfo: Interface Ethernet0/0/4 is not shutdown.[LWS5-Ethernet0/0/4]port link-t a[LWS5-Ethernet0/0/4]port de vlan 40[LWS5-Ethernet0/0/4]int e0/0/1[LWS5-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS5-Ethernet0/0/1]port link-t t[LWS5-Ethernet0/0/1]port t allow vlan all[LWS5-Ethernet0/0/1]int e0/0/2[LWS5-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS5-Ethernet0/0/2]port link-t t[LWS5-Ethernet0/0/2]port t allow vlan all[LWS5-Ethernet0/0/2]quit[LWS5]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS5]quit&lt;LWS5&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="▲S6："><a href="#▲S6：" class="headerlink" title="▲S6："></a>▲S6：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS6[LWS6]vlan 50[LWS6-vlan50]vlan 60[LWS6-vlan60]quit[LWS6]int e0/0/2[LWS6-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS6-Ethernet0/0/2]port link-t a[LWS6-Ethernet0/0/2]port de vlan 50[LWS6-Ethernet0/0/2]int e0/0/3[LWS6-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS6-Ethernet0/0/3]port link-t a[LWS6-Ethernet0/0/3]port de vlan 60[LWS6-Ethernet0/0/3]int e0/0/1[LWS6-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS6-Ethernet0/0/1]port link-t t[LWS6-Ethernet0/0/1]port t allow vlan all[LWS6-Ethernet0/0/1]quit[LWS6]quit&lt;LWS6&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="▲S1："><a href="#▲S1：" class="headerlink" title="▲S1："></a>▲S1：</h3><blockquote><p>创建VLAN</p></blockquote><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS1[LWS1]vlan 10[LWS1-vlan10]vlan 20[LWS1-vlan20]vlan 30[LWS1-vlan30]vlan 40[LWS1-vlan40]vlan 70[LWS1-vlan70]quit</code></pre><blockquote><p>配置接口</p></blockquote><pre><code>[LWS1]int g0/0/1[LWS1-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS1-GigabitEthernet0/0/1]port link-t a[LWS1-GigabitEthernet0/0/1]port de vlan 70[LWS1-GigabitEthernet0/0/1]quit[LWS1]int g0/0/2[LWS1-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS1-GigabitEthernet0/0/2]port link-t t[LWS1-GigabitEthernet0/0/2]port t allow vlan all[LWS1-GigabitEthernet0/0/2]int g0/0/3[LWS1-GigabitEthernet0/0/3]un shInfo: Interface GigabitEthernet0/0/3 is not shutdown.[LWS1-GigabitEthernet0/0/3]port link-t t[LWS1-GigabitEthernet0/0/3]port t allow vlan all[LWS1-GigabitEthernet0/0/3]int g0/0/4[LWS1-GigabitEthernet0/0/4]un shInfo: Interface GigabitEthernet0/0/4 is not shutdown.[LWS1-GigabitEthernet0/0/4]port link-t t[LWS1-GigabitEthernet0/0/4]port t allow vlan all[LWS1-GigabitEthernet0/0/4]quit</code></pre><blockquote><p>开启stp并设置为根桥(优先级为0)</p></blockquote><pre><code>[LWS1]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS1]stp prio 0</code></pre><blockquote><p>配置VLAN地址(真实网关)并设置VRRP配置虚拟网关，将S1设置为VLAN10、20的主路由器，当上行接口断了时变为备用路由器</p></blockquote><pre><code>[LWS1]int vlan 10[LWS1-Vlanif10]ip add 192.168.10.253 255.255.255.0[LWS1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1[LWS1-Vlanif10]vrrp vrid 10 prio  120[LWS1-Vlanif10]vrrp vrid 10 track int g0/0/1 reduce 30[LWS1-Vlanif10]int vlan 20[LWS1-Vlanif20]ip add 192.168.20.253 255.255.255.0[LWS1-Vlanif20]vrrp vrid 20 vi 192.168.20.1[LWS1-Vlanif20]vrrp vrid 20 prio 120[LWS1-Vlanif20]vrrp vrid 20 track int g0/0/1 reduce 30[LWS1-Vlanif20]int vlan 30[LWS1-Vlanif30]ip add 192.168.30.253 255.255.255.0[LWS1-Vlanif30]vrrp vrid 30 vi 192.168.30.1[LWS1-Vlanif30]int vlan 40[LWS1-Vlanif40]ip add 192.168.40.253 255.255.255.0[LWS1-Vlanif40]vrrp vrid 40 vi 192.168.40.1[LWS1]int vlan 70[LWS1-Vlanif70]ip add 192.168.70.253 24[LWS1-Vlanif70]quit[LWS1]quit</code></pre><blockquote><p>保存配置</p></blockquote><pre><code>&lt;LWS1&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0..Save the configuration successfully.</code></pre><blockquote><p>OSPF</p></blockquote><p>可以先用<code>dis ip int br</code>查看所有IP，再宣告网段</p><pre><code>[LWS1]ospf 1[LWS1-ospf-1]area 0.0.0.0[LWS1-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255[LWS1-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255[LWS1-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255[LWS1-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255[LWS1-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255[LWS1-ospf-1-area-0.0.0.0]quit[LWS1-ospf-1]quit[LWS1]quit&lt;LWS1&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yNow saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="▲S2："><a href="#▲S2：" class="headerlink" title="▲S2："></a>▲S2：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS2[LWS2]vlan 10[LWS2-vlan10]vlan 20[LWS2-vlan20]vlan 30[LWS2-vlan30]vlan 40[LWS2-vlan40]vlan 80[LWS2-vlan80]quit[LWS2]int g0/0/1[LWS2-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS2-GigabitEthernet0/0/1]port link-t a[LWS2-GigabitEthernet0/0/1]port de vlan 80[LWS2-GigabitEthernet0/0/1]int g0/0/2[LWS2-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS2-GigabitEthernet0/0/2]port link-t t[LWS2-GigabitEthernet0/0/2]port t allow vlan all[LWS2-GigabitEthernet0/0/2]int g0/0/3[LWS2-GigabitEthernet0/0/3]un shInfo: Interface GigabitEthernet0/0/3 is not shutdown.[LWS2-GigabitEthernet0/0/3]port link-t t[LWS2-GigabitEthernet0/0/3]port t allow vlan all[LWS2-GigabitEthernet0/0/3]int g0/0/4[LWS2-GigabitEthernet0/0/4]un shInfo: Interface GigabitEthernet0/0/4 is not shutdown.[LWS2-GigabitEthernet0/0/4]port link-t t[LWS2-GigabitEthernet0/0/4]port t allow vlan all[LWS2-GigabitEthernet0/0/4]quit[LWS2]int vlan 10[LWS2-Vlanif10]ip add 192.168.10.254 24[LWS2-Vlanif10]vrrp vrid 10 vi 192.168.10.1[LWS2-Vlanif10]int vlan 20[LWS2-Vlanif20]ip add 192.168.20.254 24[LWS2-Vlanif20]vrrp vrid 20 vi 192.168.20.1[LWS2-Vlanif20]int vlan 30[LWS2-Vlanif30]ip add 192.168.30.254 24[LWS2-Vlanif30]vrrp vrid 30 vi 192.168.30.1[LWS2-Vlanif30]vrrp vrid 30 prio 120[LWS2-Vlanif30]vrrp vrid 30 track int g0/0/1 reduce 30[LWS2-Vlanif30]int vlan 40[LWS2-Vlanif40]ip add 192.168.40.254 24[LWS2-Vlanif40]vrrp vrid 40 vi 192.168.40.1[LWS2-Vlanif40]vrrp vrid 40 prio 120[LWS2-Vlanif40]vrrp vrid 40 track int g0/0/1 reduce 30[LWS2-Vlanif40]int vlan 80[LWS2-Vlanif80]ip add 192.168.80.254 24[LWS2-Vlanif80]quit[LWS2]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS2]stp prio 4096[LWS2]quit&lt;LWS2&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.[LWS2]ospf 1[LWS2-ospf-1]area 0.0.0.0[LWS2-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255[LWS2-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255[LWS2-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255[LWS2-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255[LWS2-ospf-1-area-0.0.0.0]net 192.168.80.0 0.0.0.255[LWS2-ospf-1-area-0.0.0.0]quit[LWS2-ospf-1]quit[LWS2]quit&lt;LWS2&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yNow saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="▲S3："><a href="#▲S3：" class="headerlink" title="▲S3："></a>▲S3：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS3[LWS3]vlan 50[LWS3-vlan50]vlan 60[LWS3-vlan60]vlan 90[LWS3-vlan90]quit[LWS3]int g0/0/2[LWS3-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS3-GigabitEthernet0/0/2]port link-t t[LWS3-GigabitEthernet0/0/2]port t allow vlan all[LWS3-GigabitEthernet0/0/2]int g0/0/1[LWS3-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS3-GigabitEthernet0/0/1]port link-t a[LWS3-GigabitEthernet0/0/1]port de vlan 90[LWS3-GigabitEthernet0/0/1]quit[LWS3]int vlan 50[LWS3-Vlanif50]ip add 192.168.50.1 24[LWS3-Vlanif50]int vlan 60[LWS3-Vlanif60]ip add 192.168.60.1 24[LWS3-Vlanif60]int vlan 90[LWS3-Vlanif90]ip add 192.168.90.1 24[LWS3-Vlanif90]quit[LWS3]dhcp enInfo: The operation may take a few seconds. Please wait for a moment.done.[LWS3]ip pool vlan50Info:It&#39;s successful to create an IP address pool.[LWS3-ip-pool-vlan50]gateway-list 192.168.50.1[LWS3-ip-pool-vlan50]net 192.168.50.0 mask 255.255.255.0[LWS3-ip-pool-vlan50]quit[LWS3]ip pool vlan60Info:It&#39;s successful to create an IP address pool.[LWS3-ip-pool-vlan60]gateway-list 192.168.60.1[LWS3-ip-pool-vlan60]net 192.168.60.0 mask 255.255.255.0[LWS3-ip-pool-vlan60]quit[LWS3]quit[LWS3]int vlan50[LWS3-Vlanif50]dhcp select global[LWS3-Vlanif50]int vlan60[LWS3-Vlanif60]dhcp select global[LWS3-Vlanif60]quit[LWS3]quit&lt;LWS3&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.[LWS3]ospf 1[LWS3-ospf-1]area 0.0.0.0[LWS3-ospf-1-area-0.0.0.0]net 192.168.90.0 0.0.0.255[LWS3-ospf-1-area-0.0.0.0]net 192.168.50.0 0.0.0.255[LWS3-ospf-1-area-0.0.0.0]net 192.168.60.0 0.0.0.255[LWS3-ospf-1-area-0.0.0.0]quit[LWS3-ospf-1]quit[LWS3]quit&lt;LWS3&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yNow saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="●R1："><a href="#●R1：" class="headerlink" title="●R1："></a>●R1：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR1[LWR1]int e0/0/1[LWR1-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWR1-Ethernet0/0/1]ip add 192.168.70.50 24[LWR1-Ethernet0/0/1]int g0/0/0[LWR1-GigabitEthernet0/0/0]ip add 192.168.80.50 24[LWR1-GigabitEthernet0/0/0]int e0/0/0[LWR1-Ethernet0/0/0]ip add 192.168.100.50 24[LWR1-Ethernet0/0/0]quit[LWR1]quit&lt;LWR1&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 17.Save the configuration successfully.&lt;LWR1&gt;sysEnter system view, return user view with Ctrl+Z.[LWR1]ospf 1[LWR1-ospf-1]area 0.0.0.0[LWR1-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255[LWR1-ospf-1-area-0.0.0.0]net 192.168.80.0 0.0.0.255[LWR1-ospf-1-area-0.0.0.0]net 192.168.100.0 0.0.0.255[LWR1-ospf-1-area-0.0.0.0]quit[LWR1-ospf-1]quit[LWR1]quit&lt;LWR1&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yNow saving the current configuration to the slot 17.Save the configuration successfully.</code></pre><h3 id="●R2："><a href="#●R2：" class="headerlink" title="●R2："></a>●R2：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR2[LWR2]int e0/0/0[LWR2-Ethernet0/0/0]un shInfo: Interface Ethernet0/0/0 is not shutdown.[LWR2-Ethernet0/0/0]ip add 192.168.100.51 24[LWR2-Ethernet0/0/0]int e0/0/1[LWR2-Ethernet0/0/1]ip add 192.168.110.51 24[LWR2-Ethernet0/0/1]quit[LWR2]ospf 1[LWR2-ospf-1]area 0.0.0.0[LWR2-ospf-1-area-0.0.0.0]net 192.168.100.0 0.0.0.255[LWR2-ospf-1-area-0.0.0.0]net 192.168.110.0 0.0.0.255[LWR2-ospf-1-area-0.0.0.0]quit[LWR2-ospf-1]qu[LWR2]qu&lt;LWR2&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 17.Save the configuration successfully.</code></pre><h3 id="●R3："><a href="#●R3：" class="headerlink" title="●R3："></a>●R3：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR3[LWR3]int e0/0/0[LWR3-Ethernet0/0/0]ip add 192.168.110.50 24[LWR3-Ethernet0/0/0]int e0/0/1[LWR3-Ethernet0/0/1]ip add 192.168.90.50 24[LWR3-Ethernet0/0/1]quit[LWR3]ospf 1[LWR3-ospf-1]area 0.0.0.0[LWR3-ospf-1-area-0.0.0.0]net 192.168.90.0 0.0.0.255[LWR3-ospf-1-area-0.0.0.0]net 192.168.110.0 0.0.0.255[LWR3-ospf-1-area-0.0.0.0]quit[LWR3-ospf-1]quit[LWR3]quit&lt;LWR3&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 17.Save the configuration successfully.</code></pre><h2 id="■测试"><a href="#■测试" class="headerlink" title="■测试"></a>■测试</h2><p>Ping<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL7/pic2.png" alt=""><br>S1或S2<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL7/pic3.png" alt=""><br>S4或S5<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL7/pic4.png" alt=""></p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="eNSP" scheme="https://sakura.wallleap.cn/tags/eNSP/"/>
    
      <category term="OSPF" scheme="https://sakura.wallleap.cn/tags/OSPF/"/>
    
  </entry>
  
  <entry>
    <title>图集1-逆水寒</title>
    <link href="https://sakura.wallleap.cn/2019/09/20/atlas1/"/>
    <id>https://sakura.wallleap.cn/2019/09/20/atlas1/</id>
    <published>2019-09-20T12:15:12.000Z</published>
    <updated>2019-10-24T04:49:59.302Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><blockquote><p>《逆水寒》是由杭州网易雷火科技有限公司开发的一款武侠题材的电脑客户端游戏，属于大型多人在线角色扮演游戏，以温瑞安《四大名捕》、《说英雄谁是英雄》、《神州奇侠》三大系列小说为游戏背景。该作于2018年6月29日开启不限号不删档内测，预计于2018年内公测。</p></blockquote><blockquote><p>《逆水寒》有着较为优秀的画面表现效果和较真实的“江湖”氛围感。该作引入TressFX发丝技术，使游戏中的体积雾更加细致真实；在物理表现上使用了Havok引擎；在光照表现上该作是首款采用Enlighten全局光照技术的国产游戏。此外，在游戏的收费模式上，经过玩家票选该作将采用时间点卡收费。</p></blockquote><p>———-引自<a href="https://baike.sogou.com/v128610359.htm?fromTitle=%E9%80%86%E6%B0%B4%E5%AF%92" target="_blank" rel="noopener">搜狗百科</a></p><p>说实话，这游戏背景超级好看的，敬请欣赏：</p><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(0).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(0).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(1).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(1).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(2).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(2).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(3).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(3).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(4).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(4).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(5).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(5).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(6).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(6).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(7).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(7).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(8).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(8).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(9).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(9).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(10).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(10).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(11).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(11).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(12).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(12).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(13).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(13).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(14).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(14).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(15).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(15).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(16).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(16).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(17).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(17).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(18).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(18).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(19).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(19).jpg" /></a><a href="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(20).jpg" target="_blank" rel="noopener" data-fancybox="images" data-caption="主人没有描述我哦~"><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/cover/(20).jpg" /></a><p>以上图片来源于网络</p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="资源" scheme="https://sakura.wallleap.cn/categories/%E8%B5%84%E6%BA%90/"/>
    
      <category term="图集" scheme="https://sakura.wallleap.cn/categories/%E8%B5%84%E6%BA%90/%E5%9B%BE%E9%9B%86/"/>
    
    
      <category term="逆水寒" scheme="https://sakura.wallleap.cn/tags/%E9%80%86%E6%B0%B4%E5%AF%92/"/>
    
      <category term="图集" scheme="https://sakura.wallleap.cn/tags/%E5%9B%BE%E9%9B%86/"/>
    
  </entry>
  
  <entry>
    <title>RIP配置</title>
    <link href="https://sakura.wallleap.cn/2019/09/19/web-HCL6/"/>
    <id>https://sakura.wallleap.cn/2019/09/19/web-HCL6/</id>
    <published>2019-09-19T08:13:56.000Z</published>
    <updated>2019-10-24T04:49:59.304Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="一、实验目的"><a href="#一、实验目的" class="headerlink" title="一、实验目的"></a>一、实验目的</h2><p>配置RIP<br>说明：<br>1.交换机和三层交换机配置RIP<br>2.左边静态地址、右边DHCP<br>3.左边除了DHCP，昨天的都配上</p><h2 id="二、配置"><a href="#二、配置" class="headerlink" title="二、配置"></a>二、配置</h2><h3 id="１、拓扑"><a href="#１、拓扑" class="headerlink" title="１、拓扑"></a>１、拓扑</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic1.png" alt=""><br>IP规划：</p><pre><code>VLAN10:192.168.10.253(S1) 192.168.10.254(S2) 192.168.10.1(虚拟IP)VLAN20:192.168.20.253(S1) 192.168.10.254(S2) 192.168.20.1(虚拟IP)VLAN30:192.168.30.253(S1) 192.168.10.254(S2) 192.168.30.1(虚拟IP)VLAN40:192.168.40.253(S1) 192.168.10.254(S2) 192.168.40.1(虚拟IP)VLAN50:192.168.50.1(S3)VLAN60:192.168.60.1(S3) VLAN70:192.168.70.253(S1)-R1:192.168.70.50VLAN80:192.168.80.254(S2)-R1:192.168.80.50VLAN90:192.168.90.1(S3)-R3:192.168.90.50R1:192.168.100.50-R2:192.168.100.51R2:192.168.110.51-R3:192.168.110.50</code></pre><h3 id="２、左边PC"><a href="#２、左边PC" class="headerlink" title="２、左边PC"></a>２、左边PC</h3><p>静态IP，手动配置<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic2.png" alt=""></p><h3 id="３、右边PC"><a href="#３、右边PC" class="headerlink" title="３、右边PC"></a>３、右边PC</h3><p>DHCP，动态获取IP地址<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic3.png" alt=""></p><h3 id="４、S４"><a href="#４、S４" class="headerlink" title="４、S４"></a>４、S４</h3><p>只需要配置接口、vlan即可　S５也是</p><blockquote><p>命名</p></blockquote><pre><code>&lt;Huawei&gt;sys Enter system view, return user view with Ctrl+Z.[Huawei]sys LWS4</code></pre><blockquote><p>删除提示信息</p></blockquote><pre><code>[LWS4]un in enInfo: Information center is disabled.</code></pre><blockquote><p>创建VLAN</p></blockquote><pre><code>[LWS4]vlan 10[LWS4-vlan10]vlan 20[LWS4-vlan20]quit</code></pre><blockquote><p>接口配置</p></blockquote><pre><code>[LWS4]int e0/0/3[LWS4-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS4-Ethernet0/0/3]port link-t a[LWS4-Ethernet0/0/3]port de vlan 10[LWS4-Ethernet0/0/3]int e0/0/4[LWS4-Ethernet0/0/4]un shInfo: Interface Ethernet0/0/4 is not shutdown.[LWS4-Ethernet0/0/4]port link-t a[LWS4-Ethernet0/0/4]port de vlan 10[LWS4-Ethernet0/0/4]int e0/0/1[LWS4-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS4-Ethernet0/0/1]port link-t t[LWS4-Ethernet0/0/1]port t allow vlan all[LWS4-Ethernet0/0/1]int e0/0/2[LWS4-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS4-Ethernet0/0/2]port link-t t[LWS4-Ethernet0/0/2]port t allow vlan all[LWS4-Ethernet0/0/2]quit[LWS4]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.</code></pre><blockquote><p>保存配置</p></blockquote><pre><code>[LWS4]quit&lt;LWS4&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yInfo: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:Now saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="５、S５"><a href="#５、S５" class="headerlink" title="５、S５"></a>５、S５</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]sys LWS5[LWS5]un in enInfo: Information center is disabled.[LWS5]vlan 30[LWS5-vlan30]vlan 40[LWS5-vlan40]quit[LWS5]int e0/0/3[LWS5-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS5-Ethernet0/0/3]port link-t a[LWS5-Ethernet0/0/3]port de vlan 30[LWS5-Ethernet0/0/3]int e0/0/4[LWS5-Ethernet0/0/4]un shInfo: Interface Ethernet0/0/4 is not shutdown.[LWS5-Ethernet0/0/4]port link-t a[LWS5-Ethernet0/0/4]port de vlan 40[LWS5-Ethernet0/0/4]int e0/0/1[LWS5-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS5-Ethernet0/0/1]port link-t t[LWS5-Ethernet0/0/1]port t allow vlan all[LWS5-Ethernet0/0/1]int e0/0/2[LWS5-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS5-Ethernet0/0/2]port link-t t[LWS5-Ethernet0/0/2]port t allow vlan all[LWS5-Ethernet0/0/2]quit[LWS5]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.</code></pre><h3 id="６、S６"><a href="#６、S６" class="headerlink" title="６、S６"></a>６、S６</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS6[LWS6]vlan 50[LWS6-vlan50]vlan 60[LWS6-vlan60]quit[LWS6]int e0/0/2[LWS6-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS6-Ethernet0/0/2]port link-t a[LWS6-Ethernet0/0/2]port de vlan 50[LWS6-Ethernet0/0/2]int e0/0/3[LWS6-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS6-Ethernet0/0/3]port link-t a[LWS6-Ethernet0/0/3]port de vlan 60[LWS6-Ethernet0/0/3]int e0/0/1[LWS6-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS6-Ethernet0/0/1]port link-t t[LWS6-Ethernet0/0/1]port t allow vlan all[LWS6-Ethernet0/0/1]quit</code></pre><h3 id="７、S１"><a href="#７、S１" class="headerlink" title="７、S１"></a>７、S１</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS1[LWS1]vlan 10[LWS1-vlan10]vlan 20[LWS1-vlan20]vlan 30[LWS1-vlan30]vlan 40[LWS1-vlan40]quit[LWS1]vlan 70[LWS1-vlan70]quit[LWS1]int g0/0/1[LWS1-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS1-GigabitEthernet0/0/1]port link-t a[LWS1-GigabitEthernet0/0/1]port de vlan 70[LWS1-GigabitEthernet0/0/1]int vlan 70[LWS1-Vlanif70]ip add 192.168.70.253 24[LWS1-Vlanif70]quit[LWS1]int g0/0/2[LWS1-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS1-GigabitEthernet0/0/2]port link-t t[LWS1-GigabitEthernet0/0/2]port t allow vlan all[LWS1-GigabitEthernet0/0/2]int g0/0/3[LWS1-GigabitEthernet0/0/3]un shInfo: Interface GigabitEthernet0/0/3 is not shutdown.[LWS1-GigabitEthernet0/0/3]port link-t t[LWS1-GigabitEthernet0/0/3]port t allow vlan all[LWS1-GigabitEthernet0/0/3]int g0/0/4[LWS1-GigabitEthernet0/0/4]un shInfo: Interface GigabitEthernet0/0/4 is not shutdown.[LWS1-GigabitEthernet0/0/4]port link-t t[LWS1-GigabitEthernet0/0/4]port t allow vlan all[LWS1-GigabitEthernet0/0/4]quit</code></pre><blockquote><p> stp</p></blockquote><pre><code>[LWS1]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS1]stp prio 0</code></pre><blockquote><p>VLAN的IP及VRRP</p></blockquote><pre><code>[LWS1]int vlan 10[LWS1-Vlanif10]ip add 192.168.10.253 255.255.255.0[LWS1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1[LWS1-Vlanif10]vrrp vrid 10 prio 120[LWS1-Vlanif10]int vlan 20[LWS1-Vlanif20]ip add 192.168.20.253 255.255.255.0[LWS1-Vlanif20]vrrp vrid 20 vi 192.168.20.1[LWS1-Vlanif20]vrrp vrid 20 prio 120[LWS1-Vlanif20]int vlan 30[LWS1-Vlanif30]ip add 192.168.30.253 255.255.255.0[LWS1-Vlanif30]vrrp vrid 30 vi 192.168.30.1[LWS1-Vlanif30]int vlan 40[LWS1-Vlanif40]ip add 192.168.40.253 255.255.255.0[LWS1-Vlanif40]vrrp vrid 40 vi 192.168.40.1[LWS1-Vlanif40]quit</code></pre><blockquote><p> S1是VLAN10和VLAN20主R，设置接口监听，与路由器连接的接口有问题，则优先级降30，让S2为主R</p></blockquote><pre><code>[LWS1]int vlan 10[LWS1-Vlanif10]vrrp vrid 10 track int g0/0/1 reduce 30[LWS1-Vlanif10]int vlan 20[LWS1-Vlanif20]vrrp vrid 20 track int g0/0/1 reduce 30[LWS1-Vlanif20]quit</code></pre><blockquote><p>RIP,可以先用<code>dis ip int brief</code>查看所有IP，然后添加</p></blockquote><pre><code>[LWS1]rip 1[LWS1-rip-1]network 192.168.10.0[LWS1-rip-1]network 192.168.20.0[LWS1-rip-1]network 192.168.30.0[LWS1-rip-1]network 192.168.40.0[LWS1-rip-1]network 192.168.70.0[LWS1-rip-1]quit[LWS1]quit</code></pre><h3 id="８、S２"><a href="#８、S２" class="headerlink" title="８、S２"></a>８、S２</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS2[LWS2]int g0/0/2[LWS2-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS2-GigabitEthernet0/0/2]port link-t t[LWS2-GigabitEthernet0/0/2]port t allow vlan all[LWS2-GigabitEthernet0/0/2]int g0/0/3[LWS2-GigabitEthernet0/0/3]un shInfo: Interface GigabitEthernet0/0/3 is not shutdown.[LWS2-GigabitEthernet0/0/3]port link-t t[LWS2-GigabitEthernet0/0/3]port t allow vlan all[LWS2-GigabitEthernet0/0/3]int g0/0/4[LWS2-GigabitEthernet0/0/4]un shInfo: Interface GigabitEthernet0/0/4 is not shutdown.[LWS2-GigabitEthernet0/0/4]port link-t t[LWS2-GigabitEthernet0/0/4]port t allow vlan all[LWS2-GigabitEthernet0/0/4]quit[LWS2]vlan 10[LWS2-vlan10]vlan 20[LWS2-vlan20]vlan 30[LWS2-vlan30]vlan 40[LWS2-vlan40]quit[LWS2]vlan 80[LWS2-vlan80]quit[LWS2]int g0/0/1[LWS2-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS2-GigabitEthernet0/0/1]port link-t a[LWS2-GigabitEthernet0/0/1]port de vlan 80[LWS2-GigabitEthernet0/0/1]quit[LWS2]int vlan 80[LWS2-Vlanif80]ip add 192.168.80.254 24[LWS2-Vlanif80]quit[LWS2]int vlan 10[LWS2-Vlanif10]ip add 192.168.10.254 255.255.255.0[LWS2-Vlanif10]vrrp vrid 10 vi 192.168.10.1[LWS2-Vlanif10]int vlan 20[LWS2-Vlanif20]ip add 192.168.20.254 255.255.255.0[LWS2-Vlanif20]vrrp vrid 20 vi 192.168.20.1[LWS2-Vlanif20]int vlan 30[LWS2-Vlanif30]ip add 192.168.30.254 255.255.255.0[LWS2-Vlanif30]vrrp vrid 30 vi 192.168.30.1[LWS2-Vlanif30]vrrp vrid 30 prio 120[LWS2-Vlanif30]int vlan 40[LWS2-Vlanif40]ip add 192.168.40.254 24[LWS2-Vlanif40]vrrp vrid 40 vi 192.168.40.1[LWS2-Vlanif40]vrrp vrid 40 prio 120[LWS2-Vlanif40]quit[LWS2]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS2]stp prio 4096[LWS2]rip 1[LWS2-rip-1]net 192.168.10.0[LWS2-rip-1]net 192.168.20.0[LWS2-rip-1]net 192.168.30.0[LWS2-rip-1]net 192.168.40.0[LWS2-rip-1]net 192.168.80.0[LWS2-rip-1]quit</code></pre><h3 id="９、S３"><a href="#９、S３" class="headerlink" title="９、S３"></a>９、S３</h3><pre><code>&lt;Huawei&gt;sys Enter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS3[LWS3]vlan 50[LWS3-vlan50]vlan 60[LWS3-vlan60]vlan 90[LWS3-vlan90]quit[LWS3]int g0/0/2[LWS3-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS3-GigabitEthernet0/0/2]port link-t t[LWS3-GigabitEthernet0/0/2]port t allow vlan all[LWS3-GigabitEthernet0/0/2]int g0/0/1[LWS3-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS3-GigabitEthernet0/0/1]port link-t a[LWS3-GigabitEthernet0/0/1]port de vlan 90[LWS3-GigabitEthernet0/0/1]quit[LWS3]int vlan 50[LWS3-Vlanif50]ip add 192.168.50.1 24[LWS3-Vlanif50]int vlan 60[LWS3-Vlanif60]ip add 192.168.60.1 24[LWS3-Vlanif60]int vlan 90[LWS3-Vlanif90]ip add 192.168.90.1 24[LWS3-Vlanif90]quit[LWS3]dhcp en[LWS3]ip pool vlan50Info:It&#39;s successful to create an IP address pool.[LWS3-ip-pool-vlan50]gateway-list 192.168.50.1[LWS3-ip-pool-vlan50]net 192.168.50.0 mask 255.255.255.0[LWS3-ip-pool-vlan50]quit[LWS3]ip pool vlan60Info:It&#39;s successful to create an IP address pool.[LWS3-ip-pool-vlan60]gateway-list 192.168.60.1[LWS3-ip-pool-vlan60]net 192.168.60.0 mask 255.255.255.0[LWS3-ip-pool-vlan60]quit[LWS3]int vlan 10[LWS3-VLANIF10]dhcp select global[LWS3]rip 1[LWS3-rip-1]net 192.168.50.0[LWS3-rip-1]net 192.168.60.0[LWS3-rip-1]net 192.168.90.0[LWS3-rip-1]quit</code></pre><h3 id="１０、R１"><a href="#１０、R１" class="headerlink" title="１０、Ｒ１"></a>１０、Ｒ１</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR1[LWR1]int e0/0/0[LWR1-Ethernet0/0/0]ip add 192.168.70.50 24[LWR1-Ethernet0/0/0]int e0/0/1[LWR1-Ethernet0/0/1]ip add 192.168.80.50 24[LWR1-Ethernet0/0/1]int g0/0/0[LWR1-GigabitEthernet0/0/0]ip add 192.168.100.50 24[LWR1-GigabitEthernet0/0/0]quit[LWR1]rip 1[LWR1-rip-1]net 192.168.70.0[LWR1-rip-1]net 192.168.80.0[LWR1-rip-1]net 192.168.100.0[LWR1-rip-1]quit</code></pre><h3 id="１１、R２"><a href="#１１、R２" class="headerlink" title="１１、Ｒ２"></a>１１、Ｒ２</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]int e0/0/0[Huawei-Ethernet0/0/0]ip add 192.168.100.51 24[Huawei-Ethernet0/0/0]int e0/0/1[Huawei-Ethernet0/0/1]ip add 192.168.110.51 24[Huawei-Ethernet0/0/1]quit[Huawei]rip 1[Huawei-rip-1]net 192.168.100.0[Huawei-rip-1]net 192.168.110.0[Huawei-rip-1]quit</code></pre><h3 id="１２、R３"><a href="#１２、R３" class="headerlink" title="１２、Ｒ３"></a>１２、Ｒ３</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWR3[LWR3]int e0/0/0[LWR3-Ethernet0/0/0]ip add 192.168.110.50 24[LWR3-Ethernet0/0/0]int e0/0/1[LWR3-Ethernet0/0/1]ip add 192.168.90.50 24[LWR3-Ethernet0/0/1]quit[LWR3]rip 1[LWR3-rip-1]net 192.168.90.0[LWR3-rip-1]net 192.168.110.0[LWR3-rip-1]quit</code></pre><h2 id="三、测试"><a href="#三、测试" class="headerlink" title="三、测试"></a>三、测试</h2><blockquote><p>PC互ping</p></blockquote><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic4.png" alt=""></p><blockquote><p>S4或S5</p><pre><code>dis stp brief</code></pre><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic5.png" alt=""></p></blockquote><blockquote><p>S1或S2</p></blockquote><pre><code>dis vrrp brief</code></pre><p>接着<code>shutdown</code>S1的上层端口<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL6/pic6.png" alt=""><br>Master变为backup</p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="eNsp" scheme="https://sakura.wallleap.cn/tags/eNsp/"/>
    
      <category term="RIP" scheme="https://sakura.wallleap.cn/tags/RIP/"/>
    
  </entry>
  
  <entry>
    <title>DHCP配置(续)--DHCP中继</title>
    <link href="https://sakura.wallleap.cn/2019/09/18/web-HCL4/"/>
    <id>https://sakura.wallleap.cn/2019/09/18/web-HCL4/</id>
    <published>2019-09-18T08:14:16.000Z</published>
    <updated>2019-10-24T04:49:59.304Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><blockquote><p>实验目的：DHCP中继</p></blockquote><blockquote><p>配置：<br>拓扑如下：<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL4/pic1.jpg" alt=""></p></blockquote><h2 id="一、四个PC"><a href="#一、四个PC" class="headerlink" title="一、四个PC"></a>一、四个PC</h2><p>打开DHCP，启用接口<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL4/pic2.jpg" alt=""></p><h2 id="二、交换机S1"><a href="#二、交换机S1" class="headerlink" title="二、交换机S1"></a>二、交换机S1</h2><pre><code>&lt;H3C&gt;sysSystem View: return to User View with Ctrl+Z.[H3C]sys S1[S1]vlan 10[S1-vlan10]vlan 20[S1-vlan20]quit[S1]int g1/0/1[S1-GigabitEthernet1/0/1]no sh[S1-GigabitEthernet1/0/1]port link-type access[S1-GigabitEthernet1/0/1]port access vlan 10[S1-GigabitEthernet1/0/1]quit[S1]int g1/0/2[S1-GigabitEthernet1/0/2]no sh[S1-GigabitEthernet1/0/2]port link-t a[S1-GigabitEthernet1/0/2]port a vlan 20[S1-GigabitEthernet1/0/2]quit[S1]int g1/0/3[S1-GigabitEthernet1/0/3]no sh[S1-GigabitEthernet1/0/3]port link-t t[S1-GigabitEthernet1/0/3]port t p vlan all[S1-GigabitEthernet1/0/3]quit[S1]saveThe current configuration will be written to the device. Are you sure? [Y/N]:yPlease input the file name(*.cfg)[flash:/startup.cfg](To leave the existing filename unchanged, press the enter key):Validating file. Please wait...Saved the current configuration to mainboard device successfully.</code></pre><h2 id="三、交换机S2"><a href="#三、交换机S2" class="headerlink" title="三、交换机S2"></a>三、交换机S2</h2><pre><code>[S2]vlan 30[S2-vlan30]vlan 40[S2-vlan40]int g1/0/1[S2-GigabitEthernet1/0/1]no sh[S2-GigabitEthernet1/0/1]port link-t a[S2-GigabitEthernet1/0/1]port a vlan 30[S2-GigabitEthernet1/0/1]int g1/0/2[S2-GigabitEthernet1/0/2]no sh[S2-GigabitEthernet1/0/2]port link-t a[S2-GigabitEthernet1/0/2]port a vlan 40[S2-GigabitEthernet1/0/2]int g1/0/3[S2-GigabitEthernet1/0/3]no sh[S2-GigabitEthernet1/0/3]port link-t t[S2-GigabitEthernet1/0/3]port t p vlan all[S2-GigabitEthernet1/0/3]quit[S2]saveThe current configuration will be written to the device. Are you sure? [Y/N]:yPlease input the file name(*.cfg)[flash:/startup.cfg](To leave the existing filename unchanged, press the enter key):Validating file. Please wait...Saved the current configuration to mainboard device successfully.</code></pre><h2 id="四、交换机S3"><a href="#四、交换机S3" class="headerlink" title="四、交换机S3"></a>四、交换机S3</h2><pre><code>[S0]vlan 10[S0-vlan10]vlan 20[S0-vlan20]vlan 30[S0-vlan30]vlan 40[S0-vlan40]vlan 50[S0-vlan50]quit[S0]int g1/0/1[S0-GigabitEthernet1/0/1]no sh[S0-GigabitEthernet1/0/1]port link-t t[S0-GigabitEthernet1/0/1]port t p vlan all[S0-GigabitEthernet1/0/1]int g1/0/2[S0-GigabitEthernet1/0/2]no sh[S0-GigabitEthernet1/0/2]port link-t t[S0-GigabitEthernet1/0/2]port t p vlan all[S0-GigabitEthernet1/0/2]int g1/0/3[S0-GigabitEthernet1/0/3]no sh[S0-GigabitEthernet1/0/3]port link-t a[S0-GigabitEthernet1/0/3]port a vlan 50[S0-GigabitEthernet1/0/3]quit[S0]dhcp enable[S0]int vlan 10[S0-Vlan-interface10]%Sep 16 18:50:17:155 2019 S0 IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface10 changed to up.%Sep 16 18:50:17:155 2019 S0 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface10 changed to up.ip add 192.168.10.1 255.255.255.0[S0-Vlan-interface10]dhcp select relay[S0-Vlan-interface10]dhcp relay server-address 192.168.50.2[S0-Vlan-interface10]int vlan 20[S0-Vlan-interface20]%Sep 16 18:52:05:444 2019 S0 IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface20 changed to up.%Sep 16 18:52:05:444 2019 S0 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface20 changed to up.ip add 192.168.20.1 255.255.255.0[S0-Vlan-interface20]dhcp select relay[S0-Vlan-interface20]dhcp relay server-address 192.168.50.2[S0-Vlan-interface20]int vlan 30[S0-Vlan-interface30]%Sep 16 18:52:26:073 2019 S0 IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface30 changed to up.%Sep 16 18:52:26:073 2019 S0 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface30 changed to up.ip add 192.168.30.1 255.255.255.0[S0-Vlan-interface30]dhcp select relay[S0-Vlan-interface30]dhcp relay server-address 192.168.50.2[S0-Vlan-interface30]int vlan 40[S0-Vlan-interface40]%Sep 16 18:52:47:327 2019 S0 IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface40 changed to up.%Sep 16 18:52:47:327 2019 S0 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface40 changed to up.ip add 192.168.40.1 255.255.255.0[S0-Vlan-interface40]dhcp select relay[S0-Vlan-interface40]dhcp relay server-address 192.168.50.2[S0-Vlan-interface40]int vlan 50[S0-Vlan-interface50]%Sep 16 18:53:08:122 2019 S0 IFNET/3/PHY_UPDOWN: Physical state on the interface Vlan-interface50 changed to up.%Sep 16 18:53:08:122 2019 S0 IFNET/5/LINK_UPDOWN: Line protocol state on the interface Vlan-interface50 changed to up.ip add 192.168.50.1 255.255.255.0[S0-Vlan-interface50]quit[S0]saveThe current configuration will be written to the device. Are you sure? [Y/N]:yPlease input the file name(*.cfg)[flash:/startup.cfg](To leave the existing filename unchanged, press the enter key):Validating file. Please wait...Saved the current configuration to mainboard device successfully.</code></pre><h2 id="五、路由器R"><a href="#五、路由器R" class="headerlink" title="五、路由器R"></a>五、路由器R</h2><pre><code>[R]int g0/0[R-GigabitEthernet0/0]no sh[R-GigabitEthernet0/0]ip add 192.168.50.2 255.255.255.0[R-GigabitEthernet0/0]quit[R]dhcp en[R]dhcp server ip-pool vlan10[R-dhcp-pool-vlan10]network 192.168.10.1 mask 255.255.255.0[R-dhcp-pool-vlan10]gateway-list 192.168.10.1[R-dhcp-pool-vlan10]quit[R]dhcp server ip-pool vlan20[R-dhcp-pool-vlan20]network 192.168.20.1 mask 255.255.255.0[R-dhcp-pool-vlan20]gateway-list 192.168.20.1[R-dhcp-pool-vlan20]quit[R]dhcp server ip-pool vlan30[R-dhcp-pool-vlan30]network 192.168.30.1 mask 255.255.255.0[R-dhcp-pool-vlan30]gateway-list 192.168.30.1[R-dhcp-pool-vlan30]quit[R]dhcp server ip-pool vlan40[R-dhcp-pool-vlan40]network 192.168.40.1 mask 255.255.255.0[R-dhcp-pool-vlan40]gateway-list 192.168.40.1[R-dhcp-pool-vlan40]quit[R]ip route-static 192.168.0.0 255.255.0.0 g0/0 192.168.50.1[R]saveThe current configuration will be written to the device. Are you sure? [Y/N]:yPlease input the file name(*.cfg)[flash:/startup.cfg](To leave the existing filename unchanged, press the enter key):Validating file. Please wait...Configuration is saved to device successfully.</code></pre><blockquote><p>测试<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL4/pic3.jpg" alt=""></p></blockquote><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL4/pic4.jpg" alt=""></p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="HCL" scheme="https://sakura.wallleap.cn/tags/HCL/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/tags/%E5%8D%8E%E4%B8%89/"/>
    
  </entry>
  
  <entry>
    <title>STP及VRRP配置</title>
    <link href="https://sakura.wallleap.cn/2019/09/18/web-HCL5/"/>
    <id>https://sakura.wallleap.cn/2019/09/18/web-HCL5/</id>
    <published>2019-09-18T08:13:56.000Z</published>
    <updated>2019-10-24T04:49:59.304Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="一、实验目的"><a href="#一、实验目的" class="headerlink" title="一、实验目的"></a>一、实验目的</h2><p>1、Vrrp<br>2、Stp<br>3、能用DHCP自动获取IP<br>4、能相互ping通</p><h2 id="二、配置"><a href="#二、配置" class="headerlink" title="二、配置"></a>二、配置</h2><blockquote><p>拓扑如下</p></blockquote><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic1.png" alt=""></p><h3 id="四个PC"><a href="#四个PC" class="headerlink" title="四个PC"></a>四个PC</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic2.png" alt=""></p><h3 id="S3："><a href="#S3：" class="headerlink" title="S3："></a>S3：</h3><pre><code>&lt;Huawei&gt;sys Enter system view, return user view with Ctrl+Z.[Huawei]sys LWS3</code></pre><blockquote><p>去除提示信息</p></blockquote><pre><code>[LWS3]undo info-center enable Info: Information center is disabled.</code></pre><blockquote><p>创建VLAN</p></blockquote><pre><code>[LWS3]vlan 10[LWS3-vlan10]vlan 20[LWS3-vlan20]quit</code></pre><blockquote><p>接口配置</p></blockquote><pre><code>[LWS3]int e0/0/3[LWS3-Ethernet0/0/3]un shInfo: Interface Ethernet0/0/3 is not shutdown.[LWS3-Ethernet0/0/3]port link-type access[LWS3-Ethernet0/0/3]port default vlan 10[LWS3-Ethernet0/0/3]quit[LWS3]int e0/0/4[LWS3-Ethernet0/0/4]un shInfo: Interface Ethernet0/0/4 is not shutdown.[LWS3-Ethernet0/0/4]port link-ty a[LWS3-Ethernet0/0/4]port de vlan 20[LWS3-Ethernet0/0/4]quit[LWS3]int e0/0/1[LWS3-Ethernet0/0/1]un shInfo: Interface Ethernet0/0/1 is not shutdown.[LWS3-Ethernet0/0/1]port link-ty t[LWS3-Ethernet0/0/1]port t allow-pass vlan all[LWS3-Ethernet0/0/1]quit[LWS3]int e0/0/2[LWS3-Ethernet0/0/2]un shInfo: Interface Ethernet0/0/2 is not shutdown.[LWS3-Ethernet0/0/2]port link-ty t[LWS3-Ethernet0/0/2]port t allow vlan all[LWS3-Ethernet0/0/2]quit</code></pre><blockquote><p>开启stp</p></blockquote><pre><code>[LWS3]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.</code></pre><blockquote><p>保存配置</p></blockquote><pre><code>&lt;LWS3&gt;saveThe current configuration will be written to the device.Are you sure to continue?[Y/N]yNow saving the current configuration to the slot 0.Save the configuration successfully.</code></pre><h3 id="S4："><a href="#S4：" class="headerlink" title="S4："></a>S4：</h3><p><Huawei>sys<br>Enter system view, return user view with Ctrl+Z.<br>[Huawei]sys LWS4<br>[LWS4]un in en<br>Info: Information center is disabled.<br>[LWS4]vlan 30<br>[LWS4-vlan30]vlan 40<br>[LWS4-vlan40]quit<br>[LWS4-Ethernet0/0/3]un sh<br>Info: Interface Ethernet0/0/3 is not shutdown.<br>[LWS4-Ethernet0/0/3]port link-t a<br>[LWS4-Ethernet0/0/3]port de vlan 30<br>[LWS4-Ethernet0/0/3]quit<br>[LWS4]int e0/0/4<br>[LWS4-Ethernet0/0/4]un sh<br>Info: Interface Ethernet0/0/4 is not shutdown.<br>[LWS4-Ethernet0/0/4]port link-t a<br>[LWS4-Ethernet0/0/4]port de vlan 40<br>[LWS4-Ethernet0/0/4]quit<br>[LWS4]int e0/0/1<br>[LWS4-Ethernet0/0/1]un sh<br>Info: Interface Ethernet0/0/1 is not shutdown.<br>[LWS4-Ethernet0/0/1]port link-t t<br>[LWS4-Ethernet0/0/1]port t allow vlan all<br>[LWS4-Ethernet0/0/1]quit<br>[LWS4]int e0/0/2<br>[LWS4-Ethernet0/0/2]un sh<br>Info: Interface Ethernet0/0/2 is not shutdown.<br>[LWS4-Ethernet0/0/2]port link-t t<br>[LWS4-Ethernet0/0/2]port t allow vlan all<br>[LWS4-Ethernet0/0/2]quit<br>[LWS4]stp mode stp<br>Info: This operation may take a few seconds. Please wait for a moment…done.</p><h3 id="S1："><a href="#S1：" class="headerlink" title="S1："></a>S1：</h3><pre><code>&lt;Huawei&gt;sysEnter system view, return user view with Ctrl+Z.[Huawei]sys LWS1</code></pre><blockquote><p>去除提示信息</p></blockquote><pre><code>[LWS1]un in enInfo: Information center is disabled.</code></pre><blockquote><p>创建vlan</p></blockquote><pre><code>[LWS1]vlan 10[LWS1-vlan10]vlan 20[LWS1-vlan20]vlan 30[LWS1-vlan30]vlan 40</code></pre><blockquote><p>设置接口</p></blockquote><pre><code>[LWS1]int g0/0/1[LWS1-GigabitEthernet0/0/1]un shInfo: Interface GigabitEthernet0/0/1 is not shutdown.[LWS1-GigabitEthernet0/0/1]port link-t t[LWS1-GigabitEthernet0/0/1]port t allow vlan all[LWS1-GigabitEthernet0/0/1]quit[LWS1]int g0/0/2[LWS1-GigabitEthernet0/0/2]un shInfo: Interface GigabitEthernet0/0/2 is not shutdown.[LWS1-GigabitEthernet0/0/2]port link-t t[LWS1-GigabitEthernet0/0/2]port t allow vlan all[LWS1-GigabitEthernet0/0/2]quit[LWS1]int g0/0/3[LWS1-GigabitEthernet0/0/3]un shInfo: Interface GigabitEthernet0/0/3 is not shutdown.[LWS1-GigabitEthernet0/0/3]port link-t t[LWS1-GigabitEthernet0/0/3]port t allow vlan all[LWS1-GigabitEthernet0/0/3]quit</code></pre><blockquote><p>配置STP</p></blockquote><p><code>`</code>[LWS1]stp mode stp<br>Info: This operation may take a few seconds. Please wait for a moment…done.<br>[LWS1]stp priority 0</p><pre><code>&gt; 配置vlan地址（网关），vrrp</code></pre><p>[LWS1]int vlanif10<br>[LWS1-Vlanif10]ip add 192.168.10.1 255.255.255.0　　　<br>[LWS1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254<br>[LWS1-Vlanif10]vrrp vrid 10 prio 120<br>[LWS1-Vlanif10]int vlanif20<br>[LWS1-Vlanif20]ip add 192.168.20.1 255.255.255.0<br>[LWS1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254<br>[LWS1-Vlanif20]vrrp vrid 20 prio 120<br>[LWS1-Vlanif20]int vlanif30<br>[LWS1-Vlanif30]ip add 192.168.30.1 255.255.255.0<br>[LWS1-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254<br>[LWS1-Vlanif30]int vlanif40<br>[LWS1-Vlanif40]ip add 192.168.40.1 255.255.255.0<br>[LWS1-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254<br>[LWS1-Vlanif40]quit</p><pre><code>&gt; 配置DHCP</code></pre><p>[LWS1]dhcp en<br>Info: The operation may take a few seconds. Please wait for a moment.done.<br>[LWS1]ip pool vlan10<br>Info:It’s successful to create an IP address pool.<br>[LWS1-ip-pool-vlan10]gateway-list 192.168.10.254<br>[LWS1-ip-pool-vlan10]network 192.168.10.0 mask 255.255.255.0<br>[LWS1-ip-pool-vlan10]quit<br>[LWS1]ip pool vlan20<br>Info:It’s successful to create an IP address pool.<br>[LWS1-ip-pool-vlan20]gateway-list 192.168.20.254<br>[LWS1-ip-pool-vlan20]network 192.168.20.0 mask 255.255.255.0<br>[LWS1-ip-pool-vlan20]excluded-ip-address 192.168.20.1 192.168.20.127<br>[LWS1-ip-pool-vlan20]quit<br>[LWS1]ip pool vlan30<br>Info:It’s successful to create an IP address pool.<br>[LWS1-ip-pool-vlan30]gateway-list 192.168.30.254<br>[LWS1-ip-pool-vlan30]network 192.168.30.0 mask 255.255.255.0<br>[LWS1-ip-pool-vlan30]excluded-ip-address 192.168.30.1 192.168.30.127<br>[LWS1-ip-pool-vlan30]quit<br>[LWS1]ip pool vlan40<br>Info:It’s successful to create an IP address pool.<br>[LWS1-ip-pool-vlan40]gateway-list 192.168.40.254<br>[LWS1-ip-pool-vlan40]network 192.168.40.0 mask 255.255.255.0<br>[LWS1-ip-pool-vlan40]excluded-ip-address 192.168.40.1 192.168.40.127<br>[LWS1-ip-pool-vlan40]quit<br>[LWS1]int vlan 10<br>[LWS1-Vlanif10]dhcp select global<br>[LWS1-Vlanif10]int vlan 20<br>[LWS1-Vlanif20]dhcp select global<br>[LWS1-Vlanif20]int vlan 30<br>[LWS1-Vlanif30]dhcp select global<br>[LWS1-Vlanif30]int vlan 40<br>[LWS1-Vlanif40]dhcp select global<br>[LWS1-Vlanif40]quit</p><pre><code>### S2：</code></pre><p><Huawei>sys<br>Enter system view, return user view with Ctrl+Z.<br>[Huawei]sys LWS2<br>[LWS2]un in en<br>Info: Information center is disabled.<br>[LWS2]vlan 10<br>[LWS2-vlan10]vlan 20<br>[LWS2-vlan20]vlan 30<br>[LWS2-vlan30]vlan 40<br>[LWS2-vlan40]quit<br>[LWS2]int g0/0/1<br>[LWS2-GigabitEthernet0/0/1]un sh<br>Info: Interface GigabitEthernet0/0/1 is not shutdown.<br>[LWS2-GigabitEthernet0/0/1]port link-t t<br>[LWS2-GigabitEthernet0/0/1]port t allow vlan all<br>[LWS2-GigabitEthernet0/0/1]quit<br>[LWS2]int g0/0/2<br>[LWS2-GigabitEthernet0/0/2]un sh<br>Info: Interface GigabitEthernet0/0/2 is not shutdown.<br>[LWS2-GigabitEthernet0/0/2]port link-t t<br>[LWS2-GigabitEthernet0/0/2]port t allow vlan all<br>[LWS2-GigabitEthernet0/0/2]int g0/0/3<br>[LWS2-GigabitEthernet0/0/3]un sh<br>Info: Interface GigabitEthernet0/0/3 is not shutdown.<br>[LWS2-GigabitEthernet0/0/3]port link-t t<br>[LWS2-GigabitEthernet0/0/3]port t allow vlan all<br>[LWS2-GigabitEthernet0/0/3]quit</p><p>[LWS2]stp mode stp<br>Info: This operation may take a few seconds. Please wait for a moment…done.<br>[LWS2]stp prio 4096</p><p>[LWS2]int vlanif10<br>[LWS2-Vlanif10]ip add 192.168.10.2 24　　<br>[LWS2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254<br>[LWS2-Vlanif10]int vlanif20<br>[LWS2-Vlanif20]ip add 192.168.20.2 24<br>[LWS2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254<br>[LWS2-Vlanif20]int vlanif30<br>[LWS2-Vlanif30]ip add 192.168.30.2 24<br>[LWS2-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254<br>[LWS2-Vlanif30]vrrp vrid 30 prio 120<br>[LWS2-Vlanif30]int vlanif40<br>[LWS2-Vlanif40]ip add 192.168.40.2 24<br>[LWS2-Vlanif40]vrrp vrid 30 virtual-ip 192.168.40.254<br>[LWS2-Vlanif40]un vrrp vrid 30 virtual-ip 192.168.40.254<br>[LWS2-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254<br>[LWS2-Vlanif40]vrrp vrid 40 prio 120<br>[LWS2-Vlanif40]quit</p><p>[LWS2]dhcp en<br>Info: The operation may take a few seconds. Please wait for a moment.done.<br>[LWS2]i pool vlan10<br>Info:It’s successful to create an IP address pool.<br>[LWS2-ip-pool-vlan10]gateway-list 192.168.10.254<br>[LWS2-ip-pool-vlan10]network 192.168.10.0 mask 255.255.255.0<br>[LWS2-ip-pool-vlan10]ex 192.168.10.128 192.168.10.253<br>[LWS2-ip-pool-vlan10]quit<br>[LWS2]i pool vlan20<br>Info:It’s successful to create an IP address pool.<br>[LWS2-ip-pool-vlan20]gateway-list 192.168.20.254<br>[LWS2-ip-pool-vlan20]network 192.168.20.0 mask 255.255.255.0<br>[LWS2-ip-pool-vlan20]ex 192.168.20.128 192.168.20.253<br>[LWS2-ip-pool-vlan20]quit<br>[LWS2]i pool vlan30<br>Info:It’s successful to create an IP address pool.<br>[LWS2-ip-pool-vlan30]gateway-list 192.168.30.254<br>[LWS2-ip-pool-vlan30]network 192.168.30.0 mask 255.255.255.0<br>[LWS2-ip-pool-vlan30]ex 192.168.30.128 192.168.30.253<br>[LWS2-ip-pool-vlan30]quit<br>[LWS2]i pool vlan40<br>Info:It’s successful to create an IP address pool.<br>[LWS2-ip-pool-vlan40]gateway-list 192.168.40.254<br>[LWS2-ip-pool-vlan40]network 192.168.40.0 mask 255.255.255.0<br>[LWS2-ip-pool-vlan40]ex 192.168.40.128 192.168.40.253<br>[LWS2-ip-pool-vlan40]quit<br>[LWS2]<br>[LWS2]int vlan 10<br>[LWS2-Vlanif10]dhcp select global<br>[LWS2-Vlanif10]int vlan 20<br>[LWS2-Vlanif20]dhcp select global<br>[LWS2-Vlanif20]int vlan 30<br>[LWS2-Vlanif30]dhcp select global<br>[LWS2-Vlanif30]int vlan 40<br>[LWS2-Vlanif40]dhcp select global<br>[LWS2-Vlanif40]quit<br><code>`</code></p><h2 id="三、测试"><a href="#三、测试" class="headerlink" title="三、测试"></a>三、测试</h2><blockquote><p>PC：<br>Ipconfig查看IP然后Ping另一台PC<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic3.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic4.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic5.png" alt=""></p></blockquote><blockquote><p>S3或S4</p></blockquote><p><code>dis stp brief</code></p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic6.png" alt=""></p><blockquote><p>S1或S2</p></blockquote><p><code>dis vrrp brief</code></p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic7.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL5/pic8.png" alt=""></p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
    
      <category term="eNsp" scheme="https://sakura.wallleap.cn/tags/eNsp/"/>
    
      <category term="STP" scheme="https://sakura.wallleap.cn/tags/STP/"/>
    
  </entry>
  
  <entry>
    <title>书单1--平凡的世界</title>
    <link href="https://sakura.wallleap.cn/2019/09/15/book1/"/>
    <id>https://sakura.wallleap.cn/2019/09/15/book1/</id>
    <published>2019-09-15T11:32:39.000Z</published>
    <updated>2019-10-24T04:49:59.302Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><p>很长的一部著作，算是看过最长的了，很接地气的描写，故事一句话概括的话，应该算是：平凡青年的奋斗史。所以是不是应该把书名改为奋斗呢？所以是不是有很多这样的书呢？所以这为什么能让那么多人为之热血呢？我是带着崇拜并质疑的心态来阅读的，似乎没有能迅速找到答案，所以我便闭卷考试似的来回忆，梳理，总结，感悟，看能不能找到答案。<br>回忆三本书的故事，主人公应该是孙家一行人，衍生出来的左右旁支，亲朋好友也生存于其中；应该是黄土高原的背景，时间开始是三年自然灾害之后历时文革，改革开放这样的时间段，孙家算是几代贫农，但为人忠厚，在这样的村子里和很多贫下中农一样的活着，但是这样的孙玉厚，当家人，有着不一样的眼光，就是培养了自己的弟弟和两子一女上学，弟弟 后来成为了村里的党政管理人员，但对大哥确实不够感恩。</p><p>大哥孙少安中考考了第三，但是家里无力承担学费，便回家务农，并供养弟弟孙少平和妹妹孙兰香读书，自己成家后也承包过土地，开砖厂，扩张时倒闭了而后又东山再起，育有一子一女，老婆在日子红火了以后得了肺癌。</p><p>孙少平高中毕业，识得家中苦，也在高中自卑过，也有爱慕的人，也受田晓霞的影响开始大量的学习和阅读，最后回村教过书，务过农，不安平淡的出去闯荡，做过苦力，兼职过老师，最后扎根煤矿，他与晓霞的爱情放在现在看来是纠结的，但最后影响他最深的人也在一次洪水中，死去。</p><p>孙兰香大学毕业；天体物理学，说实话有点跳戏到三体；算是家里保护的最好的人，洗去了农村的习性，最后有好的男朋友。</p><p>其他人物有这么几个记忆深刻：</p><p>孙少安的青梅竹马，互相爱慕却最终没走在一起，嫁给了门当户对的好人家却过着寡妇的生活，在丈夫残疾后又毅然肩负家庭；润叶的朋友：已婚妇女却爱上了诗人，最后离婚；</p><p>田家的书记；弟弟先是仕途不得志而后受省里重用提拔，开启了黄原地区改革开放的新篇章；而后调任直辖市一把手；哥哥一直是村里的老八股，老谋深算不得善终；</p><p>孙少平相关联人：金波，文艺兵，因为爱上藏族姑娘，被强制退伍，八年后再去寻找，已物是人非；金波妹妹，突然结尾就爱上了少平，但是少平没有接受；师傅：死了但是对少平很好，师娘：对少平很好，少平也担负他们孤儿寡母的生活照料；第一个雇佣着：给少平迁户口，想着做女婿；</p><p>在其他的就想不起了，简单介绍完才发现写了好多，没办法，三本嘛，读完这本书有一个下意识的感觉，这本书可不那么平凡哩，因为有几处真的看着人身体发热；少安娶媳妇，少平想出去见识；少平有想法但是碍于现实做出的一段反思；少平后期的经历从搬运工到煤矿工就；润叶的一段故事；这些都是下意识的身体发热，平凡的话怎么会发热呢？后来我思考了下原因</p><p>1、婚恋：其实算算自己也不小了，看少安那段忽然让人觉得婚姻就是一个很简单但是又很幸福的事情，都让人很向往了，没有彩礼，家里一贫如洗的取了个好媳妇儿回来，多么美好，我也渴求，我也希望，但是放在这样的时代，真的是做不到啊，如果真的门当户对就好了么？这是润叶出现了，她的婚姻，其实让我很惊讶，本能觉得这女娃有点作死，好日子不过，苦了就知道相夫教子了，这样看来这婚结也难，不结也难。后来想想，老天爷看着累，让你好你怎么找都好，不让你找，怎么找都找不好；</p><p>2、当思想过于丰富，现实过于困难的时候，特别喜欢少平那一段自我剖析，八五后的我也是会有这样的想法，自认为自己有的地方很优秀，但是无法施展，这必然是要找个迁怒者的，可能是父母辈，可能是对于现实的怒吼，也可能是对自己的否定，由此长期陷入一个困局，就像DNA结构一样，螺旋延伸，但是少安他用他的肩膀，一身的伤痕，黝黑的皮肤以及最后脸上的疤痕证明了，也许生活还会一直平凡下去，但是，心不能死；因为一切都还会继续，不管是好的还是不好的方向；</p><p>3、少平的发家史，其实这段我是有过体会的，虽然没有那么刻骨，但是真心喜欢那种在苦难中咬碎牙齿也要把事情办好的过程，回想过去一年，还是自己放松了，我想我会找回那种感觉得，就在现在，从现在开始；</p><p>4、少安，少平的为人，你凭啥能获得老天的眷顾呢？还是好好为人吧，希望自己还是能多一些怜悯心，多一些责任心，多一些狠心；怜悯心要真正的最苦难有所觉悟，才会在即便是被骗的时候，依然想着好；责任心，解决自己的经济困难这是最基本的，因为你不需要拖累别人，解决自己的父母环境问题也是基本的，我希望未来我的父母能够在退休后想做点什么就做点什么，而不是日日背负着我的房贷；对亲朋好友的责任心，一世为人，为亲戚，为朋友，还是挺难得的，能帮还是帮一下，前提是我得有能力帮才行对吧；这达到这个层次我觉得跟马斯洛需求理论不谋而合；狠心，怕是我最难得解决的问题，对外不强硬，一方面本身是个性的棉条另一方面是冷感；该有的问题必须要解决，这是逃脱不掉的，不该有的问题，不要自己揽上身，怕是事多心烦哩；</p><p>梳理完这些与我学习到的东西我在思考，这本书和绝大多数励志书有什么不一样？又或者说，它凭什么得到如此高的推崇；是更贴近我们这个时代？并不是吧，毕竟文革后的改革开放那是做点事也能成的环境，我们羡慕着呢；是主人公历经九九八十一难成为了牛逼哄哄的任务？并不是吧，感觉书都没写完，对于少安来说妻子得了癌症，事业略有起色，建了个学校，对于少平，美女投怀送抱不要，心爱的人死了，自己死里逃生，励志扎根煤矿，可以调回到家乡的机会也不要，很难想象历尽艰辛之仍是艰辛是多好的结局；</p><p>答案似乎有了：在经过一千二百多页的跋涉，所有的人该生活的还是继续生活，这里没有霸道总裁，也没有天降神兵，生活还是继续，苦逼也还是继续，在经历过艰难困苦后，生活所带来的依然是艰辛，依然是困苦，但是都过来了，所以也都习惯了，所以也都成长了；</p><p>这本书似乎没有写完了，又似乎早就该写完了，我想这种真实很贴近我们，而少安的生活似乎离我们远了点，但是少平则应该成为我们的男神。</p><p>最后想写一点这个书里我不是很喜欢的一处处理，那就很多时候作者跳出了故事本身，开始用大篇幅的教育词句来进行教育，我想说，我认为的这些处有很多，我不喜欢， 经典的语句或者说直击人心的感悟应该有，但是过于泛滥了我的路遥同志，有时候黄图上的一轮明月和满目黄沙，要比很多语句都更来的——有力度。</p><p>–转自<a href="https://zhuanlan.zhihu.com/p/25104387" target="_blank" rel="noopener">知乎《平凡的世界》读书笔记</a></p>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="阅读" scheme="https://sakura.wallleap.cn/categories/%E9%98%85%E8%AF%BB/"/>
    
    
      <category term="悦读" scheme="https://sakura.wallleap.cn/tags/%E6%82%A6%E8%AF%BB/"/>
    
  </entry>
  
  <entry>
    <title>HCL配置(三)–-DHCP配置</title>
    <link href="https://sakura.wallleap.cn/2019/09/12/web-HCL3/"/>
    <id>https://sakura.wallleap.cn/2019/09/12/web-HCL3/</id>
    <published>2019-09-12T07:42:43.000Z</published>
    <updated>2019-10-24T04:49:59.304Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="HCL配置-三-–-DHCP配置"><a href="#HCL配置-三-–-DHCP配置" class="headerlink" title="HCL配置(三)–-DHCP配置"></a><font color = "red">HCL配置(三)–-DHCP配置</font></h1><h2 id="一、任务"><a href="#一、任务" class="headerlink" title="一、任务"></a>一、任务</h2><blockquote><p>在实验二的基础上(VLAN10、20、30、40内的主机之间互ping成功)实现用DHCP给各vlan内主机自动分配地址</p></blockquote><h2 id="二、配置"><a href="#二、配置" class="headerlink" title="二、配置"></a>二、配置</h2><p>由于在上一个实验的基础上，因此只需要配置四个PC和最上面的交换机S0即可</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL3/pic1.png" alt=""></p><h3 id="1、四个PC"><a href="#1、四个PC" class="headerlink" title="1、四个PC"></a>1、四个PC</h3><p>使用DHCP，启用接口</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL3/pic2.png" alt=""></p><h3 id="2、最上面的交换机S0"><a href="#2、最上面的交换机S0" class="headerlink" title="2、最上面的交换机S0"></a>2、最上面的交换机S0</h3><blockquote><p><font color = "blue">配置DHCP</font><br><code>`</code></p></blockquote><p><LwS0>sys<br>System View: return to User View with Ctrl+Z.<br>[LwS0]dhcp enable<br>[LwS0]dhcp server ip-pool vlan10<br>[LwS0-dhcp-pool-vlan10]network 192.168.10.1 mask 255.255.255.0<br>[LwS0-dhcp-pool-vlan10]gateway-list 192.168.10.1<br>[LwS0-dhcp-pool-vlan10]qui<br>[LwS0]dhcp server ip-pool vlan20<br>[LwS0-dhcp-pool-vlan20]network 192.168.20.1 mask 255.255.255.0<br>[LwS0-dhcp-pool-vlan20]gateway-list 192.168.20.1<br>[LwS0-dhcp-pool-vlan20]quit<br>[LwS0]dhcp server ip-pool vlan30<br>[LwS0-dhcp-pool-vlan30]network 192.168.30.1 mask 255.255.255.0<br>[LwS0-dhcp-pool-vlan30]gateway-list 192.168.30.1<br>[LwS0-dhcp-pool-vlan30]quit<br>[LwS0]dhcp server ip-pool vlan40<br>[LwS0-dhcp-pool-vlan40]network 192.168.40.1 mask 255.255.255.0<br>[LwS0-dhcp-pool-vlan40]gateway-list 192.168.40.1<br>[LwS0-dhcp-pool-vlan40]quit</p><pre><code>&gt; &lt;font color = &quot;blue&quot;&gt;保存配置&lt;/font&gt;</code></pre><p>[LwS0]quit</p><p><LwS0>save<br>The current configuration will be written to the device. Are you sure? [Y/N]:y<br>Please input the file name(*.cfg)[flash:/startup.cfg]<br>(To leave the existing filename unchanged, press the enter key):<br>flash:/startup.cfg exists, overwrite? [Y/N]:y<br>Validating file. Please wait…<br>Saved the current configuration to mainboard device successfully.<br><code>`</code></p><h2 id="三、测试"><a href="#三、测试" class="headerlink" title="三、测试"></a>三、测试</h2><p>查看各个PC的ip</p><p>然后ping另一台PC，能ping通即可</p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/%E5%8D%8E%E4%B8%89/"/>
    
    
      <category term="HCL" scheme="https://sakura.wallleap.cn/tags/HCL/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/tags/%E5%8D%8E%E4%B8%89/"/>
    
      <category term="实验" scheme="https://sakura.wallleap.cn/tags/%E5%AE%9E%E9%AA%8C/"/>
    
      <category term="配置" scheme="https://sakura.wallleap.cn/tags/%E9%85%8D%E7%BD%AE/"/>
    
  </entry>
  
  <entry>
    <title>HCL配置(二)--VLAN间通信</title>
    <link href="https://sakura.wallleap.cn/2019/09/11/web-HCL2/"/>
    <id>https://sakura.wallleap.cn/2019/09/11/web-HCL2/</id>
    <published>2019-09-11T10:06:05.000Z</published>
    <updated>2019-10-24T04:49:59.304Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="HCL配置-二-–VLAN间通信"><a href="#HCL配置-二-–VLAN间通信" class="headerlink" title="HCL配置(二)–VLAN间通信"></a><font color="red">HCL配置(二)–VLAN间通信</font></h1><h2 id="一、任务"><a href="#一、任务" class="headerlink" title="一、任务"></a><font color="orange">一、任务</font></h2><blockquote><p>Vlan间通信：<br>VLAN10、20、30、40内的主机之间互ping成功</p></blockquote><h2 id="二、配置"><a href="#二、配置" class="headerlink" title="二、配置"></a><font color="orange">二、配置</font></h2><h3 id="一-通过三层交换机使用SVI实现通信"><a href="#一-通过三层交换机使用SVI实现通信" class="headerlink" title="(一)通过三层交换机使用SVI实现通信"></a><font color="pink">(一)通过三层交换机使用SVI实现通信</font></h3><p>拓扑图如下：</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL2/pic1.png" alt="拓扑"></p><p>主机IP：</p><ul><li><code>PC1：　192.168.10.100/24</code></li><li><code>PC2：　192.168.20.100/24</code></li><li><code>PC3：　192.168.30.100/24</code></li><li><code>PC4：　192.168.40.100/24</code></li></ul><p>VLANIP规划：</p><ul><li><code>VLAN10：　192.168.10.1/24</code></li><li><code>VLAN20：　192.168.20.1/24</code></li><li><code>VLAN30：　192.168.30.1/24</code></li><li><code>VLAN40：　192.168.40.1/24</code></li></ul><h4 id="1、配置PC"><a href="#1、配置PC" class="headerlink" title="1、配置PC"></a>1、配置PC</h4><p>配置好IP地址，掩码，网关（网关是VLAN的IP）</p><h4 id="2、最上面的交换机S0"><a href="#2、最上面的交换机S0" class="headerlink" title="2、最上面的交换机S0"></a>2、最上面的交换机S0</h4><blockquote><p>命名<br><code>`</code></p></blockquote><p><H3C>sys<br>System View: return to User View with Ctrl+Z.<br>[H3C]sys LWS0</p><pre><code>&gt;创建四个vlan</code></pre><p>[LWS0]vlan 10<br>[LWS0-vlan10]quit<br>[LWS0]vlan 20<br>[LWS0-vlan20]vlan 30<br>[LWS0-vlan30]vlan 40<br>[LWS0-vlan40]quit</p><pre><code>&gt; 给vlan分配IP</code></pre><p>[LWS0]int vlan 10<br>[LWS0-Vlan-interface10]ip add 192.168.10.1 255.255.255.0<br>[LWS0-Vlan-interface10]quit<br>[LWS0]int vlan 20<br>[LWS0-Vlan-interface20]ip add 192.168.20.1 255.255.255.0<br>[LWS0-Vlan-interface20]int vlan 30<br>[LWS0-Vlan-interface30]ip add 192.168.30.1 255.255.255.0<br>[LWS0-Vlan-interface30]int vlan 40<br>[LWS0-Vlan-interface40]ip add 192.168.40.1 255.255.255.0<br>[LWS0-Vlan-interface40]quit</p><pre><code>&gt;接口设为trunk并允许所有vlan通过</code></pre><p>[LWS0]int g1/0/1<br>[LWS0-GigabitEthernet1/0/1]port link-type trunk<br>[LWS0-GigabitEthernet1/0/1]port trunk permit vlan all<br>[LWS0-GigabitEthernet1/0/1]no sh<br>[LWS0-GigabitEthernet1/0/1]int g1/0/2<br>[LWS0-GigabitEthernet1/0/2]no sh<br>[LWS0-GigabitEthernet1/0/2]port link-ty t<br>[LWS0-GigabitEthernet1/0/2]port t p vlan all</p><pre><code>#### 3、左边交换机S1&gt; 命名</code></pre><p><H3C>sys<br>System View: return to User View with Ctrl+Z.<br>[H3C]sys LWS1<br>创建vlan<br>[LWS1]vlan 10<br>[LWS1-vlan10]vlan 20<br>[LWS1-vlan20]quit</p><pre><code>&gt; 与交换机相连的接口设为trunk，允许所有vlan通过</code></pre><p>[LWS1-GigabitEthernet1/0/1]no sh<br>[LWS1-GigabitEthernet1/0/1]port link-ty t<br>[LWS1-GigabitEthernet1/0/1]port t p vlan all<br>[LWS1-GigabitEthernet1/0/1]quit</p><pre><code>&gt;下面两个接口设为access</code></pre><p>[LWS1]int g1/0/2<br>[LWS1-GigabitEthernet1/0/2]port link-ty a<br>[LWS1-GigabitEthernet1/0/2]port a vlan 10<br>[LWS1-GigabitEthernet1/0/2]int g1/0/3<br>[LWS1-GigabitEthernet1/0/3]no sh<br>[LWS1-GigabitEthernet1/0/3]port link-ty a<br>[LWS1-GigabitEthernet1/0/3]port a vlan 20<br>[LWS1-GigabitEthernet1/0/3]quit</p><pre><code>#### 4、右边交换机S2</code></pre><p>[LWS2]vlan 30<br>[LWS2-vlan30]vlan 40<br>[LWS2-vlan40]quit<br>[LWS2]int g1/0/1<br>[LWS2-GigabitEthernet1/0/1]port link-ty t<br>[LWS2-GigabitEthernet1/0/1]port t p vlan all<br>[LWS2-GigabitEthernet1/0/1]quit<br>[LWS2]int g1/0/2<br>[LWS2-GigabitEthernet1/0/2]port link-ty a<br>[LWS2-GigabitEthernet1/0/2]port a vlan 30<br>[LWS2-GigabitEthernet1/0/2]int g1/0/3<br>[LWS2-GigabitEthernet1/0/3]port link-ty a<br>[LWS2-GigabitEthernet1/0/3]port a vlan 40<br>[LWS2-GigabitEthernet1/0/3]quit<br><code>`</code></p><h4 id="5、测试"><a href="#5、测试" class="headerlink" title="5、测试"></a>5、测试</h4><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL2/pic2.png" alt=""></p><h3 id="二-其他方法"><a href="#二-其他方法" class="headerlink" title="(二)其他方法"></a><font color="pink">(二)其他方法</font></h3><p>其他的网上有详细的配置，因此只给出方法</p><p>1、如果只有两个VLAN，那么可以在交换机端口设置trunk的本征VLAN，自行去标签</p><p>多个VLAN的话设成Hybrid口，用untag撕去标签</p><p>2、通过路由接口</p><p>3、通过单臂路由</p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/%E5%8D%8E%E4%B8%89/"/>
    
    
      <category term="HCL" scheme="https://sakura.wallleap.cn/tags/HCL/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/tags/%E5%8D%8E%E4%B8%89/"/>
    
      <category term="实验" scheme="https://sakura.wallleap.cn/tags/%E5%AE%9E%E9%AA%8C/"/>
    
      <category term="配置" scheme="https://sakura.wallleap.cn/tags/%E9%85%8D%E7%BD%AE/"/>
    
  </entry>
  
  <entry>
    <title>HCL配置(一)--ping通及Telnet</title>
    <link href="https://sakura.wallleap.cn/2019/09/09/web-HCL1/"/>
    <id>https://sakura.wallleap.cn/2019/09/09/web-HCL1/</id>
    <published>2019-09-09T13:54:19.000Z</published>
    <updated>2019-10-24T04:49:59.303Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h1 id="HCL配置-一-–PCping通路由器及HostTelnet路由器"><a href="#HCL配置-一-–PCping通路由器及HostTelnet路由器" class="headerlink" title="HCL配置(一)–PCping通路由器及HostTelnet路由器"></a><font color="red">HCL配置(一)–PCping通路由器及HostTelnet路由器</font></h1><h2 id="一、任务"><a href="#一、任务" class="headerlink" title="一、任务"></a><font color="orange">一、任务</font></h2><blockquote><ul><li>命名R、2S为自己姓名首字母</li><li>给设备配置时间</li><li>PC能够Ping通R</li><li>Host能telnet路由器</li></ul></blockquote><h2 id="二、配置"><a href="#二、配置" class="headerlink" title="二、配置"></a><font color="orange">二、配置</font></h2><h3 id="1、新建工程并添加设备"><a href="#1、新建工程并添加设备" class="headerlink" title="1、新建工程并添加设备"></a>1、新建工程并添加设备</h3><p>单机图示图标，新建工程，自己命名选择路径保存</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic1.png" alt=""></p><p>从左边选择设备，拖入操作区，使用GE线缆将设备连接起来，连接Host的时候注意选择有线网卡<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic2.png" alt=""></p><h3 id="2、查看Host的IP并配好PC、Host相关参数"><a href="#2、查看Host的IP并配好PC、Host相关参数" class="headerlink" title="2、查看Host的IP并配好PC、Host相关参数"></a>2、查看Host的IP并配好PC、Host相关参数</h3><p>在真机环境中打开命令提示符，输入<code>ipconfig</code>获得刚刚新建的网卡IP<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic3.png" alt=""><br>图示显示169…未分配地址，打开网络管理界面，右击Vbox…网卡<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic4.png" alt=""><br>属性–找到Internet协议版本4(TCP/IPv4)，双击后配置静态IP<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic5.png" alt=""><br>禁用－启用该网卡，再次输入<code>ipconfig</code>查看IP地址<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic6.png" alt=""><br>启动所有设备<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic7.png" alt=""><br>右击PC，选择配置，输入相关参数，启用接口<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic8.png" alt=""></p><h3 id="3、路由器配置"><a href="#3、路由器配置" class="headerlink" title="3、路由器配置"></a>3、路由器配置</h3><p><kbd>Ctrl</kbd>+<kbd>C</kbd>退出自动配置，按<kbd>enter</kbd>继续</p><h4 id="1-修改名称"><a href="#1-修改名称" class="headerlink" title="(1)修改名称"></a>(1)修改名称</h4><pre><code>&lt;H3C&gt;system-viewSystem View: return to User View with Ctrl+Z.[H3C]sysname LWR</code></pre><h4 id="2-配置接口"><a href="#2-配置接口" class="headerlink" title="(2)配置接口"></a>(2)配置接口</h4><p><img src="web-HCL1/pic9.png" alt=""></p><ul><li>G0/0 192.168.11.1     </li><li>G0/1 192.168.10.1</li></ul><pre><code>[LWR]int g0/0[LWR-GigabitEthernet0/0]ip add 192.168.11.1 255.255.255.0[LWR-GigabitEthernet0/0]quit[LWR]int g0/1[LWR-GigabitEthernet0/1]ip add 192.168.10.1 255.255.255.0[LWR-GigabitEthernet0/1]quit[LWR]dis cur。。。#interface GigabitEthernet0/0 port link-mode route combo enable copper ip address 192.168.11.1 255.255.255.0#interface GigabitEthernet0/1 port link-mode route combo enable copper ip address 192.168.10.1 255.255.255.0</code></pre><h4 id="3-开启telnet服务"><a href="#3-开启telnet服务" class="headerlink" title="(3)开启telnet服务"></a>(3)开启telnet服务</h4><pre><code>[LWR]telnet server enable[LWR]user-interface vty 0 4[LWR-line-vty0-4]authentication-mode none[LWR-line-vty0-4]user level-5</code></pre><p>真机到控制面板中选择程序，启用服务，勾选Telnet Client，确定，开启telnet功能<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic10.png" alt=""></p><h3 id="4、交换机配置"><a href="#4、交换机配置" class="headerlink" title="4、交换机配置"></a>4、交换机配置</h3><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic11.png" alt=""></p><p>S1：<br><kbd>Ctrl</kbd>+<kbd>C</kbd>   <kbd>enter</kbd></p><pre><code>&lt;H3C&gt;sysSystem View: return to User View with Ctrl+Z.[H3C]sys LWS1[LWS1]int g1/0/1[LWS1-GigabitEthernet1/0/1]no sh[LWS1-GigabitEthernet1/0/1]quit[LWS1]int g1/0/2[LWS1-GigabitEthernet1/0/2]no sh[LWS1-GigabitEthernet1/0/2]quit</code></pre><p>S2：<br><kbd>Ctrl</kbd>+<kbd>C</kbd>   <kbd>enter</kbd></p><pre><code>&lt;H3C&gt;sysSystem View: return to User View with Ctrl+Z.[H3C]sys LWS2[LWS2]int g1/0/1[LWS2-GigabitEthernet1/0/1]no sh[LWS2-GigabitEthernet1/0/1]quit[LWS2]int g1/0/2[LWS2-GigabitEthernet1/0/2]no sh[LWS2-GigabitEthernet1/0/2]quit</code></pre><h3 id="5、测试"><a href="#5、测试" class="headerlink" title="5、测试"></a>5、测试</h3><h4 id="1-PCping路由器地址"><a href="#1-PCping路由器地址" class="headerlink" title="(1)PCping路由器地址"></a>(1)PCping路由器地址</h4><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic12.png" alt=""></p><h4 id="2-Host-真机-pingR并telnet"><a href="#2-Host-真机-pingR并telnet" class="headerlink" title="(2)Host(真机)pingR并telnet"></a>(2)Host(真机)pingR并telnet</h4><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic13.png" alt=""><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL1/pic14.png" alt=""></p><h3 id="6、时间配置"><a href="#6、时间配置" class="headerlink" title="6、时间配置"></a>6、时间配置</h3><p><LWR>sys<br>System View: return to User View with Ctrl+Z.<br>[LWR]clock p<br>[LWR]clock protocol none<br>[LWR]quit</p><p><LWR>clock datetime 21:53:50 2019/09/09</p><p>7、保存</p><p><LWR>save<br>The current configuration will be written to the device. Are you sure? [Y/N]:y<br>Please input the file name(*.cfg)[flash:/startup.cfg]<br>(To leave the existing filename unchanged, press the enter key):<br>Validating file. Please wait…<br>Configuration is saved to device successfully.</p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><p><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><p><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><p><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><p><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><p><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><p><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><p><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/%E5%8D%8E%E4%B8%89/"/>
    
    
      <category term="HCL" scheme="https://sakura.wallleap.cn/tags/HCL/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/tags/%E5%8D%8E%E4%B8%89/"/>
    
      <category term="实验" scheme="https://sakura.wallleap.cn/tags/%E5%AE%9E%E9%AA%8C/"/>
    
      <category term="配置" scheme="https://sakura.wallleap.cn/tags/%E9%85%8D%E7%BD%AE/"/>
    
  </entry>
  
  <entry>
    <title>HCL的安装和使用</title>
    <link href="https://sakura.wallleap.cn/2019/09/09/web-HCL0/"/>
    <id>https://sakura.wallleap.cn/2019/09/09/web-HCL0/</id>
    <published>2019-09-09T13:34:37.000Z</published>
    <updated>2019-10-24T04:49:59.303Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="HCL的安装"><a href="#HCL的安装" class="headerlink" title="HCL的安装"></a><font color="red">HCL的安装</font></h2><p>下载下面的文件</p><p><code>链接:https://pan.baidu.com/s/13kzRjgJqHXOsvRK54Waz1w  密码:mqh3</code></p><p>双击HCL_V2.1.1_Setup.exe开始安装，安装过程中注意不要勾选VBox。</p><p>安装完成之后双击VirtualBox-4.2.4-81684-Win.exe，没什么注意事项，一直下一步，点允许即可</p><h2 id="HCL使用"><a href="#HCL使用" class="headerlink" title="HCL使用"></a><font color="red">HCL使用</font></h2><p>右击HCL，选择属性</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic1.png" alt="1"></p><p>点击兼容性，按图修改</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic2.png" alt="2"></p><p>点击更改高DPI设置，勾选如图复选框</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic3.png" alt="3"></p><p>之后双击打开即可</p><p>选择两个PC测试，VMbox会相应生成设备</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic4.png" alt="4"></p><p>点击启动按钮</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic5.png" alt="5"></p><p>稍等一会右击vPC，点击配置，输入相关参数，点击启用，这时接口状态显示为ADM</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic6.png" alt="6"></p><p>勾选接口管理下方的启用选项</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic7.png" alt="7"></p><p>将两个都配置好，接口状态变为UP</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic8.png" alt="8"><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic9.png" alt="9"></p><p>双击PC，进入命令行，ping对方IP，能ping通，软件安装和使用都不会有问题了</p><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/web-HCL0/pic10.png" alt="10"></p><hr><p> <strong>文章汇总：</strong></p><p><table><tr><td bgcolor=#FFFF00> HCL的安装和使用</td></tr></table><br><kbd><a href="/2019/09/09/web-HCL0/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#D1EEEE>ping通及Telnet</td></tr></table><br><kbd><a href="/2019/09/09/web-HCL1/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#C0FF3E>VLAN间通信</td></tr></table><br><kbd><a href="/2019/09/11/web-HCL2/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#54FF9F>DHCP配置</td></tr></table><br><kbd><a href="/2019/09/12/web-HCL3/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#EFFF00> DHCP中继</td></tr></table><br><kbd><a href="/2019/09/18/web-HCL4/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#DFEEEE>STP及VRRP配置</td></tr></table><br><kbd><a href="/2019/09/18/web-HCL5/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#C0FFFE>RIP配置</td></tr></table><br><kbd><a href="/2019/09/19/web-HCL6/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#54FFEF>OSPF配置</td></tr></table><br><kbd><a href="/2019/09/27/web-HCL7/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#0FFF00>ACL+NAT配置</td></tr></table><br><kbd><a href="/2019/09/27/web-HCL8/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#F1EEEE>使用eNSP搭建企业网络</td></tr></table><br><kbd><a href="/2019/09/30/web-HCL9/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      
      
        &lt;link rel=&quot;stylesheet&quot; class=&quot;aplayer-secondary-style-marker&quot; href=&quot;/assets/css/APlayer.min.css&quot;&gt;&lt;script src=&quot;/assets/js/APlayer.min.js&quot; cla
      
    
    </summary>
    
      <category term="网络" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/categories/%E7%BD%91%E7%BB%9C/%E5%8D%8E%E4%B8%89/"/>
    
    
      <category term="HCL" scheme="https://sakura.wallleap.cn/tags/HCL/"/>
    
      <category term="华三" scheme="https://sakura.wallleap.cn/tags/%E5%8D%8E%E4%B8%89/"/>
    
      <category term="安装" scheme="https://sakura.wallleap.cn/tags/%E5%AE%89%E8%A3%85/"/>
    
  </entry>
  
  <entry>
    <title>数据结构(1)-绪论</title>
    <link href="https://sakura.wallleap.cn/2019/08/28/DataStructure1/"/>
    <id>https://sakura.wallleap.cn/2019/08/28/DataStructure1/</id>
    <published>2019-08-28T14:12:47.000Z</published>
    <updated>2019-10-24T04:49:59.302Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script>]]></content>
    
    <summary type="html">
    
      数据结构预备知识
    
    </summary>
    
      <category term="编程" scheme="https://sakura.wallleap.cn/categories/%E7%BC%96%E7%A8%8B/"/>
    
      <category term="数据结构" scheme="https://sakura.wallleap.cn/categories/%E7%BC%96%E7%A8%8B/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/"/>
    
    
      <category term="技术" scheme="https://sakura.wallleap.cn/tags/%E6%8A%80%E6%9C%AF/"/>
    
      <category term="数据结构" scheme="https://sakura.wallleap.cn/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/"/>
    
      <category term="C/C++" scheme="https://sakura.wallleap.cn/tags/C-C/"/>
    
  </entry>
  
  <entry>
    <title>数据结构(0)--预备知识</title>
    <link href="https://sakura.wallleap.cn/2019/08/25/DataStructure0/"/>
    <id>https://sakura.wallleap.cn/2019/08/25/DataStructure0/</id>
    <published>2019-08-25T02:18:51.000Z</published>
    <updated>2019-10-24T04:49:59.302Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="0-引言"><a href="#0-引言" class="headerlink" title="0.引言"></a>0.引言</h2><blockquote><p>程序(Program) = 算法(Algorithms) + 数据结构(Data Structure)<br></p></blockquote><p>数据结构需要使用程序语言来描述，比如C/C++</p><blockquote><p>以下是C/C++的第一个程序</p></blockquote><pre><code class="C">#include &lt;stdio.h&gt;           // 预处理指令#include &lt;stdlib.h&gt;          // 将stdio.h和stdlib.h引入程序，stdio中包含标准输入输出函数 stdlib为标准库头文件，一些宏和一些函数如malloc()、system()等需要用到 在C++中为cstdio、cstdlibint main()                  // main函数函数头{                           // {...}为函数体    printf(&quot;Hello World&quot;);  // 打印语句    return 0;               // 函数返回0，0称为函数返回值}// 注释：单行注释使用&quot;//&quot;,块注释使用&quot;/* */&quot;,Java中文档注释使用&quot;/** */&quot;</code></pre><pre><code class="C++">#include &lt;iostream&gt;using namespace std;        // 使用std这个命名空间，函数体中使用cout、cin就不需要写成std::cout、std::cin的格式了int main(){    cout &lt;&lt; &quot;Hello World&quot; &lt;&lt;endl;    return 0;}//main(int argc,char *argv[])--带参数的main函数 argc代表命令行参数的个数，argv[0]存放的是命令，argv[i]存放的是命令行中的第i个参数(i&gt;=1)eg:ping 192.168.1.1   argc=1;argv[0]=&quot;ping&quot;;argv[1]=&quot;192.168.1.1&quot;;</code></pre><p>C/C++程序运行：源程序test.c(.cpp)-<code>编译</code>-&gt;二进制文件test.obj-<code>连接</code>-&gt;test.exe(或其他可执行文件)-<code>运行</code>-&gt;运行成功或失败</p><h2 id="1-变量和数据类型"><a href="#1-变量和数据类型" class="headerlink" title="1.变量和数据类型"></a>1.变量和数据类型</h2><ul><li><blockquote><p>常量</p></blockquote></li></ul><p><code>常量</code>是程序运行过程中值不能改变的量<br><code>(1)整型常量</code>：如10000，0，-345<br><code>(2)实型常量</code>：123.4，0.0，-9.79，12.34e3(12.34x10^3)<br><code>(3)字符常量</code>：普通字符如’a’，’Z’，’3’，’?’及转义字符\n，\t等<br><code>(4)字符串常量</code>：”hello”，”12346”<br><code>(5)符号常量</code>：不占内存</p><pre><code>#define PI 3.1415926</code></pre><pre><code>const float PI = 3.14159f;</code></pre><ul><li><blockquote><p>变量</p></blockquote></li></ul><p><code>变量</code>代表一个有名字的、具有特定属性的一个存储单元，用来存放变量的值，变量的值是可以改变的。变量必须先定义，后使用。<br><code>变量定义</code>：</p><pre><code>&lt;数据类型&gt; &lt;变量名1&gt;[,&lt;变量名2&gt;,···];</code></pre><p>如<code>int a;</code>  <code>char c;</code>  <code>double b;</code>  <code>bool isE;</code>等<br><code>变量名</code>使用标识符来标识。用来对变量、符号常量名、函数、数组、类型等命名的有效字符徐磊统称为<code>标识符</code>。标识符由大小写字母、数字字符和下划线组成，且第一个字符不能为数字，还有用户定义的标识符不能和系统保留关键字同名。<br>在同一个作用域中不能有两个或两个以上相同的变量名<br><code>变量赋值和初始化</code><br>(1)定义后赋值</p><pre><code>int x,y;x = 8;y = x;</code></pre><p>(2)定义的同时赋值</p><pre><code>int n = 1;double d = 1.25;char c = &#39;a&#39;;</code></pre><p>(3)定义多个变量时单独赋一个</p><pre><code>int n1, n2 = 4, n3;</code></pre><p>(4)C++中</p><pre><code>int n1(1), n2(4), n3;       //定义三个整型变量n1、n2、n3,且赋初值n1为1、n2为4</code></pre><ul><li><blockquote><p>保留关键字</p></blockquote></li></ul><p><code>asm</code> <code>auto</code> <code>break</code> <code>case</code> <code>catch</code>  <code>char</code>  <code>class</code>  <code>const</code>  <code>continue</code>  <code>default</code>  <code>delete</code>  <code>do</code>  <code>double</code> <code>else</code>  <code>enum</code>  <code>extern</code>  <code>float</code>  <code>for</code> <code>friend</code>  <code>goto</code>  <code>if</code>  <code>inline</code>  <code>int</code>  <code>long</code>  <code>new</code>  <code>operator</code>  <code>private</code>  <code>protected</code>  <code>public</code>  <code>register</code>  <code>return</code>  <code>short</code>  <code>signed</code>  <code>sizeof</code>  <code>static</code>  <code>struct</code>  <code>switch</code>  <code>template</code>  <code>this</code>  <code>throw</code>  <code>try</code>  <code>typedef</code>  <code>union</code>  <code>unisigned</code>  <code>virtual</code>  <code>void</code>  <code>volatile</code>  <code>while</code></p><ul><li><blockquote><p>数据类型</p></blockquote></li></ul><p><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/DataStructure0/pic1.jpg" alt="数据类型"><br>使用<code>sizeof()</code>获取数据类型字宽</p><ul><li><blockquote><p>运算符和表达式</p></blockquote></li></ul><ul><li><code>算术运算符</code>：四则运算(<code>+</code> 、<code>-</code>、<code>*</code>、<code>/</code>),求余(<code>%</code>),自增(<code>++</code>),自减(<code>--</code>)</li><li><code>关系运算符</code>：大等小(<code>&gt;</code>、<code>&gt;=</code>、<code>==</code>、<code>&lt;</code>、<code>&lt;=</code>),不等(<code>!=</code>)</li><li><code>逻辑运算符</code>：与或非(<code>&amp;&amp;</code>、<code>||</code>、<code>!</code>)</li><li><code>位运算符</code>：按位与(<code>&amp;</code>)、按位或(<code>|</code>)、按位异或(<code>^</code>)、取反(<code>~</code>)、左移(<code>&lt;&lt;</code>)、右移(<code>&gt;&gt;</code>)</li><li><code>赋值运算符</code>：赋值(<code>=</code>),扩展(<code>+=</code>、<code>-=</code>、<code>/=</code>、<code>*=</code>、<code>%=</code>···)</li><li><code>条件运算符</code>：(<code>? :</code>)</li><li><code>逗号运算符</code>：(<code>,</code>)</li><li><code>指针运算符</code>：(<code>*</code>、<code>&amp;</code>)</li><li><code>求字节数运算符</code>：(<code>sizeof()</code>)</li><li><code>强制类型转换运算符</code>：(<code>(&lt;type&gt;)</code>)</li><li><code>成员运算符</code>：(<code>.</code>、<code>-&gt;</code>)</li><li><code>下标运算符</code>：(<code>[]</code>)</li><li><code>其他</code>：函数调用(<code>()</code>)</li></ul><p><em>注意运算符的优先级，运算顺序</em></p><ul><li><code>运算符表达式</code>–用算术运算符和括号将运算对象连接起来的，符合C/C++语法规则的式子</li></ul><ul><li><blockquote><p>语句</p></blockquote></li></ul><ul><li><strong>控制语句</strong> –控制功能语句<ul><li>条件语句 <code>if()···else···</code></li><li>循环语句 <code>for()···</code>、<code>while()···</code>、<code>do···while();</code></li><li>结束本次循环 <code>continue</code></li><li>终止执行switch语句或循环语句 <code>break</code></li><li>多分支选择语句 <code>switch()</code></li><li>函数返回语句 <code>return</code></li><li>转向语句 <code>goto</code></li></ul></li><li><strong>函数调用语句</strong> –函数调用加分号结尾<ul><li><code>printf(&quot;1&quot;);</code></li><li><code>max(1,2);</code></li></ul></li><li><strong>表达式语句</strong> –表达式加分号结尾<ul><li>赋值语句 <code>a=3;</code></li><li><code>i++;</code></li></ul></li><li><strong>空语句</strong> <code>;</code> 只有一个分号，什么也不做</li><li><strong>复合语句</strong> –用<code>{}</code>把语句和声明括起来，又称语句块</li></ul><p><em>函数体包含声明部分和执行部分，执行部分是由语句组成的，语句的作用是向计算机系统发出操作指令，要求执行相应的操作。</em></p><h2 id="2-输入输出"><a href="#2-输入输出" class="headerlink" title="2.输入输出"></a>2.输入输出</h2><blockquote><p>input：</p></blockquote><ul><li><code>scanf(&quot;%c&quot;,&amp;s);</code></li><li><code>a = getchar();</code></li><li><code>gets();</code></li><li><code>std::cin &gt;&gt; a;</code></li></ul><blockquote><p>output:</p></blockquote><ul><li><code>printf(&quot;%s&quot;,s);</code></li><li><code>putchar(a);</code></li><li><code>puts();</code></li><li><code>std::cout &lt;&lt; a &lt;&lt;endl;</code></li></ul><blockquote><p>格式控制</p></blockquote><ul><li><code>%d</code>、<code>%i</code>–十进制整型</li><li><code>%o</code>–八进制整型</li><li><code>%x</code>、<code>%X</code>–十六进制数</li><li><code>%u</code>–无符号型</li><li><code>%c</code>–字符</li><li><code>%s</code>–字符串</li><li><code>%f</code>–6位小数单双精度</li><li><code>%e</code>、<code>%E</code>–指数形式的实型</li><li><p><code>%g</code>、<code>%G</code>–自动选择%f %e</p></li><li><p><code>%l</code>–长整型，加在d、o、x、u前</p></li><li><code>%-m.nf</code>–向左靠齐，m个宽度，n为小数的实数</li></ul><h2 id="3-三大基本结构"><a href="#3-三大基本结构" class="headerlink" title="3.三大基本结构"></a>3.三大基本结构</h2><blockquote><p>顺序结构</p></blockquote><p><em>在顺序结构中，各语句是自上而下的顺序执行的，执行完上一个语句就自动执行下一个语句，是无条件的，不需要作任何判断。是最简单的程序结构。</em></p><blockquote><p>选择(分支)结构</p></blockquote><ul><li>根据某个条件是否满足来决定是否执行指定的操作</li></ul><p><strong>if语句</strong> 选择结构</p><pre><code>if(表达式) 语句1[else 语句2]/*此处的表达式主要为：关系表达式 （a&gt;b）==c逻辑表达式  !a&amp;&amp;(b||c)条件表达式  a&gt;b ? (max=a) : (max=b)*/</code></pre><p><em>注意if语句的嵌套</em></p><ul><li>满足条件后从给定的两种或多种操作选择其一</li></ul><p><strong>switch语句</strong> 多分支选择结构</p><pre><code>switch(表达式){    case 常量1:语句1 break;    case 常量2:语句2 break;        ·        ·        ·    case 常量n:语句n break;    default:语句n+1}/*·表达式的值为整数类型·表达式中的值满足下面的常量i,则case 常量i,执行语句i·遇到break跳出switch，一直没有break则一直按顺序往下执行语句·没有找到常量i,则执行default后的语句，如果没有default也没找到常量i则不执行任何语句·每个常量必须不同·case只起标记作用·多个case标号可以共用一组执行语句*/</code></pre><blockquote><p>循环结构</p></blockquote><ul><li><strong>while语句</strong></li></ul><pre><code>while(表达式){    循环体}/* 先判断表达式，后执行循环语句 */</code></pre><ul><li><strong>do···while语句</strong></li></ul><pre><code>do{    循环体}while(表达式);/* 先无条件执行循环体，然后判断循环条件是否成立。因此最少需要执行循环体一次。 */</code></pre><ul><li><strong>for语句</strong></li></ul><pre><code>for(循环变量赋初值;循环条件;循环变量增值){    循环体}/* 表达式可以省，但是分号要保留 */</code></pre><ul><li><strong>循环的嵌套</strong></li></ul><p>注意分析即可</p><ul><li><strong>改变循环执行状态</strong></li></ul><p><code>continue</code>：结束本次循环<br><code>break</code>:终止整个循环</p><a id="more"></a><h2 id="4-数组"><a href="#4-数组" class="headerlink" title="4.数组"></a>4.数组</h2><p><code>数组</code>是相同类型的元素的有序集合。每个元素在内存中占用相同大小的内存单元，这些内存单元在内存空间中都是连续存放的。</p><blockquote><p>一维数组</p></blockquote><ul><li>定义<br><code>类型 数组名[常量表达式];</code> 比如<code>int a[10];</code>这是一个含有a[0]到a[9]十个元素的名字为a的数组</li></ul><ul><li><p>引用<br><code>数组名[下标]</code></p></li><li><p>初始化</p><ul><li>在定义时对所有数组元素初始化 <code>int a[5] = {0,1,2,3,4};</code></li><li>定义时部分元素初始化，其余为0 <code>int a[5] = {0,1};</code></li><li>全部赋值为0 <code>int a[5] = {0,0,0,0,0};</code>或<code>int a[5] = {0};</code></li><li>对全部袁术赋初值时，数据个数已定了，故可省略 <code>int a[] = {0,1,2,3,4};</code></li></ul></li></ul><blockquote><p>二维数组</p></blockquote><ul><li>定义</li></ul><p><code>类型 数组名[常量表达式1][常量表达式2];</code>比如<code>float a[3][4],b[5][10];</code>,C中存放数组是按行优先的</p><ul><li>引用<br><code>数组名[下标][下标]</code></li></ul><ul><li>初始化<ul><li>分行赋值 <pre><code>int a[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};</code></pre></li><li>不分行   <pre><code>int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12};</code></pre></li><li>部分元素赋值  <pre><code>int a[3][4] = {{1},{5},{9}};</code></pre></li><li>全部元素赋值，只能省前面维度的数值 <pre><code>int a[][4] = {1,2,3,4,5,6,7,8,9,10,11,12};</code></pre></li><li>分行赋值省前面维度 <pre><code>int a[][4] = {{0,0,3},{},{0,10}};</code></pre></li></ul></li></ul><h2 id="5-字符串"><a href="#5-字符串" class="headerlink" title="5.字符串"></a>5.字符串</h2><blockquote><p>字符数组</p></blockquote><blockquote><p>string类</p></blockquote><blockquote><p>字符串处理函数</p></blockquote><h2 id="6-函数"><a href="#6-函数" class="headerlink" title="6.函数"></a>6.函数</h2><h2 id="7-递归"><a href="#7-递归" class="headerlink" title="7.递归"></a>7.递归</h2><h2 id="8-指针和引用"><a href="#8-指针和引用" class="headerlink" title="8.指针和引用"></a>8.指针和引用</h2><h2 id="7-结构体"><a href="#7-结构体" class="headerlink" title="7.结构体"></a>7.结构体</h2>]]></content>
    
    <summary type="html">
    
      数据结构预备知识
    
    </summary>
    
      <category term="编程" scheme="https://sakura.wallleap.cn/categories/%E7%BC%96%E7%A8%8B/"/>
    
      <category term="数据结构" scheme="https://sakura.wallleap.cn/categories/%E7%BC%96%E7%A8%8B/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/"/>
    
    
      <category term="数据结构" scheme="https://sakura.wallleap.cn/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/"/>
    
      <category term="C/C++" scheme="https://sakura.wallleap.cn/tags/C-C/"/>
    
  </entry>
  
  <entry>
    <title>Mac使用Hexo和GitHub搭建博客(4)--博客维护</title>
    <link href="https://sakura.wallleap.cn/2019/08/25/mac-blog4/"/>
    <id>https://sakura.wallleap.cn/2019/08/25/mac-blog4/</id>
    <published>2019-08-25T01:30:28.000Z</published>
    <updated>2019-10-24T04:49:59.303Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script>]]></content>
    
    <summary type="html">
    
      Hexo+GitHub Pages搭建博客
    
    </summary>
    
      <category term="笔记" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/"/>
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/Hexo/"/>
    
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/tags/Hexo/"/>
    
      <category term="GitHub" scheme="https://sakura.wallleap.cn/tags/GitHub/"/>
    
      <category term="Blog" scheme="https://sakura.wallleap.cn/tags/Blog/"/>
    
      <category term="博客" scheme="https://sakura.wallleap.cn/tags/%E5%8D%9A%E5%AE%A2/"/>
    
  </entry>
  
  <entry>
    <title>Mac使用Hexo和GitHub搭建博客(3)--发布文章</title>
    <link href="https://sakura.wallleap.cn/2019/08/25/mac-blog3/"/>
    <id>https://sakura.wallleap.cn/2019/08/25/mac-blog3/</id>
    <published>2019-08-25T00:46:41.000Z</published>
    <updated>2019-10-24T04:49:59.303Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="0-准备工作"><a href="#0-准备工作" class="headerlink" title="0.准备工作"></a>0.准备工作</h2><blockquote><p>上一个文章有提到过修改 <code>scaffolds/post.md</code> 达到修改博文模板的作用</p></blockquote><pre><code>--- title: {{ title }}   #文章标题，可以和文件名不同date: {{ date }}  #发布时间categories:      #分类    - category    - subcategorytags:                #标签    - tag1    - tag2---</code></pre><blockquote><p>前面博客中还提到过插入图片的，这里总结一下</p><ul><li>下面这个要填写你使用github.io访问博客的地址</li></ul></blockquote><pre><code># URL## If your site is put in a subdirectory, set url as &#39;http://yoursite.com/child&#39; and root as &#39;/child/&#39;url: http://wallleap.github.io</code></pre><ul><li><p>这个需要改成true</p><pre><code>post_asset_folder: true</code></pre></li><li><p>安装插件</p><pre><code>npm install hexo-assert-folder --save</code></pre></li></ul><p>但是这个插件的内容需要修改【不然可能会出Bug】</p><p>打开/node_modules/hexo-asset-image/index.js，将内容更换为下面的代码  </p><pre><code>&#39;use strict&#39;;var cheerio = require(&#39;cheerio&#39;);// http://stackoverflow.com/questions/14480345/how-to-get-the-nth-occurrence-in-a-stringfunction getPosition(str, m, i) {return str.split(m, i).join(m).length;}var version = String(hexo.version).split(&#39;.&#39;);hexo.extend.filter.register(&#39;after_post_render&#39;, function(data){var config = hexo.config;if(config.post_asset_folder){var link = data.permalink;if(version.length &gt; 0 &amp;&amp; Number(version[0]) == 3)var beginPos = getPosition(link, &#39;/&#39;, 1) + 1;elsevar beginPos = getPosition(link, &#39;/&#39;, 3) + 1;// In hexo 3.1.1, the permalink of &quot;about&quot; page is like &quot;.../about/index.html&quot;.var endPos = link.lastIndexOf(&#39;/&#39;) + 1;link = link.substring(beginPos, endPos);var toprocess = [&#39;excerpt&#39;, &#39;more&#39;, &#39;content&#39;];for(var i = 0; i &lt; toprocess.length; i++){var key = toprocess[i];var $ = cheerio.load(data[key], {ignoreWhitespace: false,xmlMode: false,lowerCaseTags: false,decodeEntities: false});$(&#39;img&#39;).each(function(){if ($(this).attr(&#39;src&#39;)){// For windows style path, we replace &#39;\&#39; to &#39;/&#39;.var src = $(this).attr(&#39;src&#39;).replace(&#39;\\&#39;, &#39;/&#39;);if(!/http[s]*.*|\/\/.*/.test(src) &amp;&amp;!/^\s*\//.test(src)) {// For &quot;about&quot; page, the first part of &quot;src&quot; can&#39;t be removed.// In addition, to support multi-level local directory.var linkArray = link.split(&#39;/&#39;).filter(function(elem){return elem != &#39;&#39;;});var srcArray = src.split(&#39;/&#39;).filter(function(elem){return elem != &#39;&#39; &amp;&amp; elem != &#39;.&#39;;});if(srcArray.length &gt; 1)srcArray.shift();src = srcArray.join(&#39;/&#39;);$(this).attr(&#39;src&#39;, config.root + link + src);console.info&amp;&amp;console.info(&quot;update link as:--&gt;&quot;+config.root + link + src);}}else{console.info&amp;&amp;console.info(&quot;no src attr, skipped...&quot;);console.info&amp;&amp;console.info($(this));}});data[key] = $.html();}}});</code></pre><h2 id="1-新建文章md文件"><a href="#1-新建文章md文件" class="headerlink" title="1.新建文章md文件"></a>1.新建文章md文件</h2><p>在终端输入<code>hexo new &quot;文章英文名&quot;</code> <em>比如</em> <code>hexo new &quot;first-blog&quot;</code>   ，将会在source/_posts下生成一个 <code>文章名.md</code> 文件 <em>比如</em> <code>first-blog.md</code>  ，同时生成一个同名文件夹 <code>first-blog</code> ，写文章的时候可以将图片放到该文件夹中。</p><h2 id="2-修改文章内容"><a href="#2-修改文章内容" class="headerlink" title="2.修改文章内容"></a>2.修改文章内容</h2><p>手动进入目录 <code>source/_posts</code>，打开刚刚新建的md文件，这里可以选择使用不同的编辑器，或者在一些网站上（比如CSDN）写好了再复制进来。</p><p>打开文件，你可以看到 <em>例</em> </p><pre><code>--- title: first-blogdate: 2019-08-29categories:     -     - tags:    -     - ---</code></pre><p>现在需要修改内容了</p><pre><code>```---title: 我的第一篇博文      #文章标题date:2019-08-29           categories:         #如果开启了多级分类，则可以按下面这样写，分类显示二级分类，文章在博客下的心得分类中    - 博客         #-前面tab，后面一个空格    - 心得tags:                  #可以这样写，会显示blog,博客,心得三个标签         - blog    - 博客    - 心得---下面写文章内容，markdown语言，自己搜一下.比如  ## 二级标题             #注意空格&gt; 引用或强调```C++std::cout &lt;&lt; &quot;hello&quot; &lt;&lt; endl;```</code></pre><h2 id="3-发布文章"><a href="#3-发布文章" class="headerlink" title="3.发布文章"></a>3.发布文章</h2><p><code>hexo d</code><br><code>hexo s</code> ，打开网页测试，没错误就可以输入下面的命令了<br><code>hexo d -g</code></p><hr><p> <strong>文章汇总：</strong></p><table><tr><td bgcolor=#FFFF00> Mac使用Hexo和GitHub搭建博客(1)</td></tr></table><p><kbd><a href="../mac-blog1/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#D1EEEE>Mac使用Hexo和GitHub搭建博客(2)</td></tr></table><p><kbd><a href="../mac-blog2/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#C0FF3E>Mac使用Hexo和GitHub搭建博客(3)</td></tr></table><p><kbd><a href="../mac-blog3/index.html">go-&gt;</a></kbd></p><table><tr><td bgcolor=#54FF9F>Mac使用Hexo和GitHub搭建博客(4)</td></tr></table><p><kbd><a href="../mac-blog4/index.html">go-&gt;</a></kbd></p><hr><p><code></code></p>]]></content>
    
    <summary type="html">
    
      Hexo+GitHub Pages搭建博客
    
    </summary>
    
      <category term="笔记" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/"/>
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/Hexo/"/>
    
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/tags/Hexo/"/>
    
      <category term="GitHub" scheme="https://sakura.wallleap.cn/tags/GitHub/"/>
    
      <category term="Blog" scheme="https://sakura.wallleap.cn/tags/Blog/"/>
    
      <category term="博客" scheme="https://sakura.wallleap.cn/tags/%E5%8D%9A%E5%AE%A2/"/>
    
  </entry>
  
  <entry>
    <title>Mac使用Hexo和GitHub搭建博客(2)--优化配置</title>
    <link href="https://sakura.wallleap.cn/2019/08/24/mac-blog2/"/>
    <id>https://sakura.wallleap.cn/2019/08/24/mac-blog2/</id>
    <published>2019-08-24T12:21:59.000Z</published>
    <updated>2019-10-24T04:49:59.303Z</updated>
    
    <content type="html"><![CDATA[<link rel="stylesheet" class="aplayer-secondary-style-marker" href="/assets/css/APlayer.min.css"><script src="/assets/js/APlayer.min.js" class="aplayer-secondary-script-marker"></script><h2 id="一、修改-config-yml"><a href="#一、修改-config-yml" class="headerlink" title="一、修改_config.yml"></a>一、修改_config.yml</h2><p>搭建博客的时候顺便改了下基本的配置，现在来看下这些配置修改</p><blockquote><p> ~/blog/_config.yml</p></blockquote><p>这个是全局的配置文件，<a href="../Mac使用Hexo和GitHub搭建博客-1/index.html">上一个博客</a>已经讲的很清楚了，这里不再赘述<br>由于需要用主题3-hexo高亮代码，将这里的高亮渲染关闭</p><pre><code>highlight:    enable: false</code></pre><blockquote><p>~/blog/themes/3-hexo/_config.yml<br>这个是主题的配置文件，仅给出需要修改的地方</p></blockquote><blockquote><p>你的头像url  需要到～/blog/themes/3-hexo/source/img下把avatar.jpg替换为自己头像</p><pre><code>avatar: /img/avatar.jpgfavicon: /img/avatar.jpg</code></pre><p>博客位置，如果没有错误不需要修改<br><code>blog_path: /</code><br>链接图标  将链接全部改为自己的即可<br> <code>csdn: https://me.csdn.net/qq_36949103</code><br>多作者模式  按需求填写</p><pre><code>author:    on: false    authors:        author1: luwang        author2: wallleap</code></pre><p>分类文章数、多级分类 按需启用 </p><pre><code>category:    num: true # 分类显示文章数    sub: true # 开启多级分类</code></pre><p>文末声明  改为自己的<br><code>`</code>article_txt: </p></blockquote><pre><code>&gt; 打赏功能  需要到～/blog/themes/3-hexo/source/img下把weixin.jpg和alipay.jpg替换为自己微信和支付宝收款码</code></pre><p>reward: true</p><pre><code>&gt; 其他的都有说明，自己看着修改就行&gt; 评论系统启用方式：[完美替代多说-gitment](https://yelog.org/2017/06/26/gitment/)## 二、优化页面### 1、主页 `~/blog/themes/3-hexo/indexs.md`由于是.md文件，因此可以按照正常的Markdown语法进行修改### 2、发布页模板 `~/blog/scaffolds/post.md`为了以后写博文方便，可以按照习惯修改模板，我的模板如下：</code></pre><hr><p>title: Mac使用Hexo和GitHub搭建博客(2)--优化配置<br>date: 1566649319000<br>tags: </p><pre><code>- tag1- tag2</code></pre><p>categories: </p><pre><code>- category1- category2</code></pre><hr><p><code>`</code><br>标签改为多标签，分类为二级分类</p><h3 id="3、其他页面"><a href="#3、其他页面" class="headerlink" title="3、其他页面"></a>3、其他页面</h3><p><code>hexo new page &quot;about&quot;</code><br>还有category等都可以添加</p><p>about页还需要修改主题_config.yml：<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic1.jpg" alt=""></p><h2 id="三、域名解析"><a href="#三、域名解析" class="headerlink" title="三、域名解析"></a>三、域名解析</h2><h3 id="1、域名解析"><a href="#1、域名解析" class="headerlink" title="1、域名解析"></a>1、域名解析</h3><p>进入到购买域名的控制台，找到域名服务或解析服务<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic2.jpg" alt=""><br>点击自己域名后的解析设置<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic3.jpg" alt=""><br>点击添加记录<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic4.jpg" alt=""><br>按照下图填写，注意记录值填<code>自己的用户名.github.io</code><br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic5.jpg" alt=""><br>也可以再添加主机记录用www的，这样输入www也能访问<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic6.jpg" alt=""></p><h3 id="2、添加文件"><a href="#2、添加文件" class="headerlink" title="2、添加文件"></a>2、添加文件</h3><p>做完了解析工作还是不行的，需要在仓库加上CNAME文件，文件中只需要填写域名，比如我的：<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/ mac-blog2/pic7.jpg" alt=""><br>由于仓库中上传时会自动删除，因此放到<code>~/blog/source/</code>下</p><h2 id="四、评论系统"><a href="#四、评论系统" class="headerlink" title="四、评论系统"></a>四、评论系统</h2><p>上面主题配置中有提到过，但对于一个博客而言，评论部分是不可或缺的，因此将其单独说明。</p><p>由于本人只用过<code>gitment</code>和<code>gitalk</code>，而个人感觉<code>gitalk</code>更好用一点，因此这里介绍<code>gitalk</code>使用，上面有<code>gitment</code>的教程链接<br>首先打开主题配置文件(<code>~/blog/themes/3-hexo/_config.yml</code>),找到评论设置，将comment字段的on设为true，type设为gitalk。找到gitalk字段，添加on:true,其他的评论系统字段添加on:false.接着打开链接<a href="https://github.com/settings/applications/new" target="_blank" rel="noopener">https://github.com/settings/applications/new</a>,登录GitHub账户，<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic8.jpg" alt=""></p><p>注意callbalk URL一定要是自己域名的地址，接着点击绿色按钮，把Client ID和Client Secret复制到主题配置文件的gitalk字段相应位置，接着githubID和adminUser填自己的用户名即可,repo填博客的仓库(即<code>用户名.github.io</code>)<br><img src="https://cdn.jsdelivr.net/gh/wallleap/cdn@latest/img/pic/mac-blog2/pic9.jpg" alt=""></p><hr><p> <strong>文章汇总：</strong></p><p><table><tr><td bgcolor=#FFFF00> Mac使用Hexo和GitHub搭建博客(1)</td></tr></table><br><kbd><a href="../mac-blog1/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#D1EEEE>Mac使用Hexo和GitHub搭建博客(2)</td></tr></table><br><kbd><a href="../mac-blog2/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#C0FF3E>Mac使用Hexo和GitHub搭建博客(3)</td></tr></table><br><kbd><a href="../mac-blog3/index.html">go-&gt;</a></kbd></p><p><table><tr><td bgcolor=#54FF9F>Mac使用Hexo和GitHub搭建博客(4)</td></tr></table><br><kbd><a href="../mac-blog4/index.html">go-&gt;</a></kbd></p><hr>]]></content>
    
    <summary type="html">
    
      Hexo+GitHub Pages搭建博客
    
    </summary>
    
      <category term="笔记" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/"/>
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/categories/%E7%AC%94%E8%AE%B0/Hexo/"/>
    
    
      <category term="Hexo" scheme="https://sakura.wallleap.cn/tags/Hexo/"/>
    
      <category term="GitHub" scheme="https://sakura.wallleap.cn/tags/GitHub/"/>
    
      <category term="Blog" scheme="https://sakura.wallleap.cn/tags/Blog/"/>
    
      <category term="博客" scheme="https://sakura.wallleap.cn/tags/%E5%8D%9A%E5%AE%A2/"/>
    
  </entry>
  
</feed>
