本系列文章是博主hojun日常业余折腾HEXO所总结的经验结果,不一定是最佳实践。了解更多请关注HEXO官方网站。关于HEXO主题已经折腾过好多,当然拆腾的都是比较有条理的。
有关HEXO主题Sakura已经是去年(前年)的事了,第一次提交:honjun committed on 20 Dec 2018。偶尔怀旧下23333~,之前关于Sakura主题开发也录了大部分的视频教程,不过估计大部分人没有看,毕竟直接拿来用更香。这次准备出文章教程,顺带练习下我那半吊子的五笔打字。
回归到正文,先总结下该教程的计划,首先html页面不准备写,去html5up上找个模版,众所周知(不知道的现在也知道了)这个网站已经出了好几个HEXO博客,包括Phantom、Massively、strata、simplyspoke、Editorial(还没做完,看完教程的可以用这个模版练练手,给它PR完整)。
最后,选定story就刚刚决定的。
首先来到hexo官网,你要折腾某个东西的时候,它的官网是一定要逛的。
找到自定义主题我们可以看到:(请务必认真看完再往后阅读)
假设你已经看完上图的文档了,开始开发主题了。首先还是要新建一个hexo博客,在卡在这一步的时候就可以Ctrl+C停止了。
用subline打开新建好的博客(Story),可以看到在themes目录下空空如也,反正我们准备自己开发一个,空的正好。
这个时候就要想到文档里的目录结构了:
新建如下:(当然要给主题建个目录,这里就叫story好了)
建好这后记得上级目录的_config.yml里面修改配置:
有好奇的小伙伴可以试着运行看看:
不要担心,这是我们没有用npm安装依赖,因为上一步的时候直接ctrl+c跳过了。使用npm i命令安装。(有切换过淘宝镜像的可以使用cnpm i安装,npm安装淘宝镜像自行百度)
可以看到安装成功后使用hexo s发布真的能跑起来,不过当我们访问的时候就会报No layout: index.html这个错。简单理解下它意思,没有layout(布局,或者说模版):index.html。
那么我们就应该建一个layout来展示index.html。不过在建之前要先确定用哪种模版引擎,官方文档如是说到:Hexo 内建 Swig 模板引擎,您可以另外安装插件来获得 EJS、Haml 或 Jade 支持。这里为了简单,学习成本低,采用了ejs模板引擎。文档也说的很明白了,用ejs我们还要安装。不过看了下package.json,hexo4.0已经集成了hexo-renderer-ejs,所以用ejs也不用安装了,直接用就是。(Jade等还是要另外安装插件的)
模板引擎选好之后,就可以新建模版页面了。在新建前要好好看下官方文档的模版说明。看完之后可以自己构思下怎么做
t
h
i
n
k
i
n
g
想不出来的可以参考下别人或者官方的主题是怎么做的。
我们在阅读文档模版后,可以知道如下信息:
模板决定了网站内容的呈现方式,每个主题至少都应包含一个 index 模板,以下是各页面相对应的模板名称:
布局(Layout),如果页面结构类似,例如两个模板都有页首(Header)和页脚(Footer),您可考虑通过「布局」让两个模板共享相同的结构。一个布局文件必须要能显示 body 变量的内容,如此一来模板的内容才会被显示,举例来说:
每个模板都默认使用 layout 布局,您可在 front-matter 指定其他布局,或是设为 false 来关闭布局功能,您甚至可在布局中再使用其他布局来建立嵌套布局。
关于front-matter可以查下以下文档了解更多front-matter
Front-matter 是文件最上方以 --- 分隔的区域,用于指定个别文件的变量,举例来说:---title: Hello Worlddate: 2013/7/13 20:46:25---
根据以上文档,我们就可以建模版页面了。其中每个主题至少都应包含一个 index 模板
和每个模板都默认使用 layout 布局
,所以我们先建个layout.ejs和index.ejs
index.ejs内容如下:
layout.ejs内容如下:其中<%- body %>
文档中并没有做出详细解释,可以理解body为页面内容。首页就是引入index.ejs,归档页就是引入archive.ejs这样。至于<%- %>
的语法可以去参考ejs文档(看不懂的,就是没好好看文档。)
hexo s 生成运行如下,可以看到我们的模版页编译成功了。(生成了layout的头部和尾部,并成功显示出了index中的内容)
好了,主题页面就是这样构建的,接下来开始把从html5up上下载的story写成我们的主题。
解压得到:
在subline中打开其index页面如下
我们要拆解这个页面,从简单的header和footer开始,将其代码收缩,可以就大致分出header、body、和footer了。
再看官方文档中关于局部模版的说明,我想你已经学会怎么拆分了
文件夹这样建立:
稍难点的layout这样写:
但是这样拆分还是有些问题,比如有部分的footer内容在index中,暂时把这部分代码直接剪切到footer.ejs中
运行后页面如下所示:
页面这种显示的原因是我们没有导入js、css。
source
资源文件夹,除了模板以外的 Asset,例如 CSS、JavaScript 文件等,都应该放在这个文件夹中。文件或文件夹开头名称为 _(下划线线)或隐藏的文件会被忽略。
如果文件可以被渲染的话,会经过解析然后储存到 public 文件夹,否则会直接拷贝到 public 文件夹。
所以我们的 CSS、JavaScript、Images 文件要放在source文件夹中,怎么放我就不赘述了。说说怎么引入。可以hexo g先生成public文件夹,看一下目录结构:
可以看到对于最外层的index.html来说,引入可以使用更通用的相对路径写法./css/xxx.css
(./表示当前目录下),但是这种写法放在hello-world下的文章页index.html就不适用了。必需使用绝对路径写法/css/
(/表示从根目录开始)所以可以使用如下写法引入:
<link rel="stylesheet" href="/css/main.css" /><noscript><link rel="stylesheet" href="/css/noscript.css" /></noscript>
但是这种写法也有一个问题,若你的博客不是放在网站根目录也是不生效的。所以hexo辅助函数css(),js()就有意义了。
<%- css(path, ...) %><%- js(path, ...) %>
最终改写成如下:
<head> <title>Story by HTML5 UP</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <%- css(['/css/main.css', '/css/noscript.css']) %></head>
js雷同。
把layout中的注释改成html注释,hexo s 运行预览下:
可以看到页面已经正常了,图片路径自行修改下就可以呈现。
从这教成开始代码开始变多起来,我把代码同步上传到github仓库和百度云上,~关注公众号Creators创作者回复story002获取。
我们已经搭建好了首页,上篇教程已经引入了css和js,接下来还是引入网站上的一些图标。
上篇教程自行引入图片其实是不用的,因为我们建立的图片文件夹正好是images,和原来的html5up模板刚好一致。让我们看下代码:
<div class="image"> <img src="images/banner.jpg" alt="" /></div>
但是也和之前的问题一样,用这种的话一定要把网站放到根目录访问,所以可以用到hexo的辅助函数“url_for”,
img代码改成如下即可:
<div class="image"> <img src="<%- url_for('/images/banner.jpg') %>" alt="" /></div>
接下来回到正题,引入图标,首先确定下这个模板的图标是字体图标,字体文件在webfonts文件夹下:
为了方便,就直接把这个文件夹复制到主题source下,hexo s 后就可以看到图标已经呈现出来了
开始着手完善首页,首先删掉一些不需要的元素
在index.ejs中的这个Five、Six、Seven分别是图集、图标、留言部分,首页不需要这些,我们给它删掉。
接下来看剩下的代码:
one是最上面的那个,图片占一半那种。自成一派先不管。two、three、four则是下面的部分。我们可以给它看做是文章列表。可以看出这几个的元素都一致,就是three的class是orient-left,所以可以删除多余的three、four后网页显示如下:
接下来考虑往首页填充内容了。不过在这之前还有很多东西要讲下(后悔用文章教程了,出视频的话会快很多55555)
首先,分析下我们首页或者说文章需要哪些东西。标题、封面图、简介还有一些给我们的如分类、标签、时间等等。这些东西都要我们自己建吗?hexo给了我们一个Scaffold文件夹,在官方文档的写作里面有说明:
打开scaffolds>post.md(就是新建文章的模板)可以看到如下内容:(顺带再提,这个在hexo中叫Front-matter)
---title: {{ title }}date: {{ date }}tags:---
可以看到hexo给文章模板预置了title、date、tags,但是我们还需要封面图、简介、分类等等,我们直接修改post.md就可以让hexo生成我们想要的模板。修改的模板如下:(keywords是关键字,对网站seo有好处)
---title: {{ title }}date: {{ date }}tags:categories:keywords:description:photos:---
这里为了更方便我们可以给一些项预设初值。比如分类和封面图。
---title: {{ title }}date: {{ date }}tags:categories: 技术keywords:description:photos: /images/pic01.jpg---
好了,接下来可以使用 hexo n “你想要的文章名” 来创建文章了。这里我们创建了八篇文章:
记住把第一个hello world.md删掉,因为这个是hexo init生成的,在它的Front-matter中没有一些项,不删除可能会导致一些错误。
好了,测试文章也有了,现在我们要去给首页填充起来。现在我们再来看index.ejs中的one和two,发现one其实和three一样是orient-left,不过多了个fullscreen的css,所以可以只剩下一个two。修改后two的代码如下:
<!-- Two --><% page.posts.each(function(post){ %> <section class="spotlight style1 orient-right content-align-left image-position-center onscroll-image-fade-in"> <div class="content"> <h2><%= post.title %></h2> <p><%= post.description %></p> <ul class="actions stacked"> <li><a href="#" class="button">Learn More</a></li> </ul> </div> <div class="image"> <img src="<%= post.photos %>" alt="" /> </div> </section><% }) %>
其中each/forEach函数(和js中的each差不多)参考model.js和query.js,post参考变量。
hexo s后生成如下:
怎样将它弄成之前那种左右交替呢?最简单的可以使用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%;}
稍微解释一下这个css,
nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型。
odd 和 even 是可用于匹配下标是奇数或偶数的子元素的关键词(第一个子元素的下标是 1)。
使用公式 (an + b)。描述:表示周期的长度,n 是计数器(从 0 开始),b 是偏移值。
就是匹配.spotlight.style1这俩class的元素。even表示偶数,就表示偶数项为row-reverse(设置
元素内弹性盒元素的方向为相反的顺序,参考flex布局),奇数项为row。所以就能实现左右左右的效果。而first-child则表示第一项,100vh表示 “相对于视口的高度,视口被均分为100单位的vh” 即铺满屏幕。最终效果如下
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story003获取。
上篇教程已经把首页内容给填充上去了,接下来继续给首页添加上分页。在文档辅助函数里有关如下
直接复制这段代码到index.ejs最下面:
<div class="paginator"> <%- paginator({ prev_text: '<i class="fa fa-angle-left"></i>', next_text: '<i class="fa fa-angle-right"></i>', escape: false }) %></div>
为了看到效果将根目录下config中的per_page改为三,表示每页三篇文章,这样我们八篇文章就会有三页了
index_generator: path: '' per_page: 3 order_by: -date
hexo s后的效果如下:
样式有点不能忍受,用f12工具查看其html代码如下:
<div class="paginator"> <span class="page-number current">1</span> <a class="page-number" href="/page/2/">2</a> <a class="page-number" href="/page/3/">3</a> <a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a></div>
为了方便直接在index.ejs中写css如下:(最终效果如下图)
<style> .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; }</style>
首先在_partial下新建article.ejs,里面代码如下:(story居然没有文章页的模板233,果然好模板都被人用了)
<article> <%- page.content %></article>
然后在index.ejs中的a标签中加入文章超链接:
<div class="content"> <h2><a href="<%- url_for(post.path) %>"><%= post.title %></a></h2> <p><%= post.description %></p> <ul class="actions stacked"> <li><a href="<%- url_for(post.path) %>" class="button">Learn More</a></li> </ul></div>
那么怎样让文章页能更根据我们的article.ejs页生成呢?回到一开始的模板介绍:
按照hexo的文档来,post是用来显示文章的,我们在layout目录下新建这几个ejs(post、page、archive、category、tag),然后暂且把article中的内容复制到post.ejs下,hexo s预览下效果:
已经是能渲染出来了,但是md里面还没有内容,这里我直接把这篇文章的md复制到测试的md中
样式又差不行不行,这个留到下篇教程再美化,现在把之前留下的问题解决,乍一看article.ejs是无用武之地了,不过考虑到page这个单页面的渲染和post差不多一致,所以我们要把文章部分抽离到article.ejs中,这样就可以复用代码了。抽离在教程二中就已经讲到,用局部模版(Partial),代码如下:
<%- partial('_partial/article', {post: page}) %>
后面的{post: page}表示把page变量存到post中传递给了article,所以article中的代码就要改为:
<article> <%- post.content %></article>
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story004获取。
上篇文章已经可以跳转到文章详情页了,这篇教程先来美化下详情页的样式。
首先打开我们从html5up上下载的story网页,浏览器上打开index-demo.html那个,在演示完图标之后有“Additional Elements”
可以看到这部分用来当文章详情页的容器挺合适。修改代码如下:
<article class="wrapper style1 align-left"> <div class="inner"> <%- post.content %> </div></article>
可以看出这个页面还缺一些必要的内容,如标题。添加后如下:
<article class="wrapper style1 align-left"> <div class="inner"> <div class="header"> <h1 class="title"><%- post.title %></h1> <div> <span>日期:<%- post.date %></span> <span>字数:<%- post.count %></span> </div> </div> <%- post.content %> </div></article>
main.css
/* 添加的css项 */.title { font-size: 3rem; font-weight: 700;}article h2 { font-size: 1.7rem;}
可以看到网页上的日期显示的是一串数字,其实这个是日期的时间戳
百度百科:时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总毫秒数。通俗的讲, 时间戳是一份能够表示一份数据在一个特定时间点已经存在的完整的可验证的数据。它的提出主要是为用户提供一份电子证据, 以证明用户的某些数据的产生时间。在实际应用上, 它可以使用在包括电子商务、 金融活动的各个方面, 尤其可以用来支撑公开密钥基础设施的 “不可否认” 服务。
来到hexo官网,搜索date:
修改成下图:
<span>日期:<%- date(post.date, 'YYYY/M/D') %></span>
页面显示如下:
和官方例子不一样,应该是文档错了。那如果要文档里那种显示该如何修改代码呢?接下来部分是干货,会举一反三的话能自己解决很多问题。分析下,date()这个函数归类在辅助函数helper里。所以先去找有没有hexo-helper-date的包,(在node_modules里找)。没找到,因为这个官方的辅助函数,试着在hexo-cli和hexo里面找。在node_modules_hexo@4.2.0@hexo\lib\plugins\helper\中找到我们要的date.js这个文件。打开它可以看到
它都原封不动的调用了 Moment.js,所以我们在hexo文档中直接点击date说明上面那个 Moment.js 的超链接去看 Moment.js 文档。找到了如下表:
那就简单了,改成自己想要的日期显示类型就行。参考如下:
<span><%- date(post.date, 'MMMM DD, YYYY, dddd ') %></span>
接下来改成中文月份,只要在根目录的config下把language改为zh-cn即可。(为啥知道,看文档和源)
日期解决后就要来看下字数,现我们已经知道文章内容在post.contant里。用post.content.length这种写法会把html标签也算进去,hexo给我们提供了strip_html字符串处理函数:
所以只要strip_html(post.content).length这种写法就好了。效果如下:
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story005获取。
阅读次数采用不蒜子来实现
复制这两行代码,引入js的那段放到footer.ejs中,span的那段放在文章详情页中。
<article class="wrapper style1 align-left"> <div class="inner"> <div class="header"> <h1 class="title"><%- post.title %></h1> <div class="stuff"> <span><%- date(post.date, 'MMMM DD, YYYY') %></span> <span>字数 <%- strip_html(post.content).length %></span> <span id="busuanzi_container_site_pv">阅读 <span id="busuanzi_value_site_pv"></span></span> </div> </div> <%- post.content %> </div></article>
前往valine.js.org官网,查看文档:
关于valine和leandcloud一些配置项请参考另一篇文章《hexo评论系统之valine快速使用》,这里就不赘述了。假设你已经有了API_ID和API_Key了,我们先把valine官方文档快速开始中的html片段复制到article.ejs(即文章详情页中),因为我们是在页面body中了,所以要把head和body删掉,修改后代码如下:
<!-- valine评论 --><script src='//unpkg.com/valine/dist/Valine.min.js'></script><div id="vcomments"></div><script> new Valine({ el: '#vcomments', appId: '<API_ID>', appKey: '<API_Key>' })</script>
接下来可以把API_ID和API_Key填入就可以使用了,不过这是开发主题,所以最好要把这些变量在配置里面赋值。在主题下的config里面输入如下:
valine: API_ID: 这里填你的API_ID API_Key: 这里填你的API_Key
接着修改valine部分代码如下:
<!-- valine评论 --><script src='//unpkg.com/valine/dist/Valine.min.js'></script><div id="vcomments"></div><script> new Valine({ el: '#vcomments', appId: '<%- theme.valine.API_ID %>', appKey: '<%- theme.valine.API_Key %>' })</script>
网页上显示如下:
valine评论的样式乱了,使用f12工具发现main.css把input元素设为了块级元素(还有其他一些问题),所以在css中加入
#vcomments input { display: inline-block;}#vcomments button { height: 2.25rem;}
因为在valine的显示中是有评论数这个选项的。但文档里面并没有给我们提供这个接口,所以我们可以自行调用valine的函数来获取。代码如下:(看源码无所不能)
<article class="wrapper style1 align-left"> <div class="inner"> <div class="header"> <h1 class="title"><%- post.title %></h1> <div class="stuff"> <span><%- date(post.date, 'MMMM DD, YYYY') %></span> <span>字数 <%- strip_html(post.content).length %></span> <span>评论 <span id="valine-count"></span></span> <span id="busuanzi_container_site_pv">阅读 <span id="busuanzi_value_site_pv"></span></span> </div> </div> <%- post.content %> <!-- valine评论 --> <script src='//unpkg.com/valine/dist/Valine.min.js'></script> <script src='//cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js'></script> <div id="vcomments"></div> <script> var valine = new Valine(); valine.init({ el: '#vcomments', appId: '<%- theme.valine.API_ID %>', appKey: '<%- theme.valine.API_Key %>' }) valine.Q(location.pathname.replace(/index\.html?$/, '')).count().then(num => { document.getElementById("valine-count").innerHTML = num; }) </script> </div></article>
效果如下:
这里直接使用了自己当前主题的代码,这个功能实现起来只要知道hexo官方文档中page变量就行:
代码和效果如下:
<div class="post-nav"> <% if (post.prev){ %> <div class="post-nav-prev post-nav-item"> <a href="<%- url_for(post.prev.path) %>" ><%= post.prev.title %><i class="fa fa-chevron-left"></i></a> </div> <% } %> <% if (post.next){ %> <div class="post-nav-next post-nav-item"> <a href="<%- url_for(post.next.path) %>" ><%= post.next.title %><i class="fa fa-chevron-right"></i></a> </div> <% } %></div>
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story006获取。
打算在hr的上边添加文章的标签,用f2开发者工具调试如下:
先到css的8551行把margin调为0:
hr { margin: 0 0 0 0;}
接着在hr上面添加html元素,先写好再调样式:
<div class="tags"> <span>标签:</span> <a href="" class="tag">XX标签</a> <a href="" class="tag">XX标签</a></div>
再写css,可以自行添加一些交互效果,自由发挥:
.tags a { font-size: 15px; padding: 3px 5px; text-decoration: none;}.tags a:hover{ color: #fff; background: #333;}
当然现在的标签不是文章设置的标签,来到官网可以看到:
所以只要把page.tags循环输出即可。
<div class="tags"> <span>标签:</span> <% post.tags.each(function(tag){%> <a href="" class="tag">{{ tag.name }}</a> <% }) %></div>
当然了,再查看效果前你要给md加上标签才行:
---title: story6date: 2020-01-18 22:11:30tags: - tag1 - tag2categories: 技术keywords:description:photos: /images/pic01.jpg---
光显示了名称还不行,还要跳转到相关页面,那url怎么获取呢?官方文档中并未做详细说明,可以去看源码。不过最简单的还是把tag输出就知道了,在tags循环中加入console.log:
<% post.tags.each(function(tag){%> <% console.log(tag) %> <a href="" class="tag"><%= tag.name %></a><% }) %>
可以看到cmd输出如下:
所以tag.path就可以获取到url了
<div class="tags"><span>标签:</span><% post.tags.each(function(tag){%> <a href="<%- url_for(tag.path) %>" class="tag"><%= tag.name %></a><% }) %></div>
再上一步加好url后,尝试点击标签,会跳转到一个页面:
为啥除了footer全是空白。回想一下之前的文章详情页的时候是不是也这样,再次回顾文档:
加上这句:
每个模板都默认使用 layout 布局,您可在 front-matter 指定其他布局,或是设为 false 来关闭布局功能,您甚至可在布局中再使用其他布局来建立嵌套布局。
分析一下,链接跳转tag模板,默认使用layout:
<html> <!-- //头部模版 --> <%- partial('_partial/header') %> <body class="is-preload"> <!-- //内容模版 --> <%- body %> <!-- //尾部模版 --> <%- partial('_partial/footer') %> </body></html>
所以在加载了footer和header(header只是引用css等,不会在页面显示),然后<%- body %>加载了tag模板。而我们的tag模板里啥都没有,所以显示空白。
tag页怎么建好呢,没想好的可以参考下其他主题点击标签后的效果。等你想好前可以试着验证下上一步的分析推论,在tag.ejs下加入如下代码:(可以看到页面出来了)
<h1>This is Tags page</h1><h1>This is Tags page</h1><h1>This is Tags page</h1><h1>This is Tags page</h1><h1>This is Tags page</h1>
回到正题,tags页面应该显示什么?点击某一个标签,一个标签对应n篇文章(至少有一篇)。所以应该显示的是属于该标签下的文章列表页。所以tag.ejs中应该写显示文章列表页的代码,等等!index首页是显示文章列表页,tag是显示文章列表页,将来分类category也是显示文章列表页,我们应该把显示文章列表页部分单独抽离出来。hexo大部分主题用archive来表示文章列表页,但归档页也叫archive,这里为了好理解,就叫post-list好了。
在_partial下新建post-list.ejs文件,把index中的文章列表部分代码复制进去。(应该是全部233333,因为首页没其他东西了)
然后index和tag页都只要简单的引用post-list就行了。
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story007获取。
现在的页面右边留空太多了,整体看上去不够居中。所以调下css:
article.wrapper.style1 > .inner { padding: 2rem 2.5rem 3rem 2.5rem; margin: 50px auto; width: 960px; box-shadow: 1px 0px 5px 1px #ccc;}
接着图片和代码块超出了范围:
article.wrapper.style1 > .inner img { width: 100%;}article.wrapper.style1 .highlight { overflow: auto;}
如果觉得目录有需要的继续往下看,这里直接安利我之前开发的hexo插件hexo-helper-tocbot及教程hexo-helper-tocbot插件使用教程。
在cmd中使用npm或cnpm安装:
npm i hexo-helper-tocbot --save
安装好后在主题下的config中添加教程中的配置:
tocbot: contentSelector: .post-content scrollSmooth: true headingSelector: h1, h2, h3, h4, h5 headingsOffset: 45 scrollSmoothOffset: -45
其中headingsOffset和scrollSmoothOffset要和你主题的头部高度相对应。含义详见API
最后在article.ejs中添下如下代码(注意,这里要把content用
包起来才能识别)
网上找了个svg按钮,放上去,然后把a的href改为javascript:history.back(-1)就行,修改后代码如下:(可自由发挥,找更棒的)
<article class="wrapper style1 align-left"> <!-- 返回按扭 --> <a href="javascript:history.back(-1)" class="cd-nav-trigger"> <span class="cd-nav-icon"></span> <svg x="0px" y="0px" width="54px" height="54px" viewBox="0 0 54 54"> <circle fill="transparent" stroke="#656e79" stroke-width="1" cx="27" cy="27" r="25" stroke-dasharray="157 157" stroke-dashoffset="157"></circle> </svg> </a> ...... ......
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: ''; 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);}
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story008获取。
继续完善主题,老实说能从一跟着练习到这里的人,开发一个自己的hexo主题已经不是什么难事了。(前题有html、js、css[学习这三最快的地方首推w3cshool])。开发到这里其实已经讲的差不多了。剩下一些功能都是类似或可有可无的。比如分类和标签是类似的,单页面都是一样的,今天我个就来开发一个单页面。
即archive页,如果还记得之前的教程或有认真看过hexo文档的话,应该知道它是官方给出的六大模板之一。这也是它特殊的地方。如果你打开hexo根目录的package.json的话就能发现:(关于package.json是干啥用自行百度,好奇能使你进步)
archive、category、index、tag都在里面,而且都是hexo-generator开头的。那么hexo-generator又是什么呢?来到hexo官网的api页:
而且也举了归档页面的例子来向我们说明:
认真看懂它。
意思是生成archives/index.html这个文件,提供的数据为所有的文章(data: locals.posts,),渲染的模板是archive,没有archive就用index替补(layout: [‘archive’, ‘index’])
好了好了不扯了,关于hexo运行原理一时半会儿也说不完。
以上扯了这么久就是说我们直接在archive.ejs里面撸代码就行了。嗯嗯网上找了个模板,样子如下:
先直接将代码复制到archive.ejs中,在source/css中新建archive.css,把需要的css复制其中。再在archive.ejs中引入,部分代码如下:
<%- css(['/css/archive.css']) %><div class="content"> <article> <h3>2013</h3> <section> <span class="point-time point-yellow"></span> <time datetime="2013-03"> <span>March</span> <span>2013</span> </time> <aside> <p class="things">The FAW</p> <p class="brief"><span class="text-yellow">Award</span> (Miami. FL)</p> </aside> </section> <section> <span class="point-time point-red"></span> <time datetime="2013-03"> <span>March</span> <span>2013</span> </time> <aside> <p class="things">You reached 500 followers on Twitter</p> <p class="brief"><span class="text-red">Social Appearance</span></p> </aside> </section> </article>
hexo s后,在浏览器地址栏输入localhost:4000/archives/就能访问到:
找到archive的页面变量:(page.year和page.month是undefined,可能哪里需要设置)
然后去把测试的md文章都改下时间。万事具备,接下来开始修改html代码:
<%- css(['/css/archive.css']) %><div class="content"> <% console.log(page)%> <% page.posts.each(function(post){ %> <% console.log(post.title)%> <% }) %> <article>
这里说明一下,8,9,5都是我改了后还是2020年的,2019和2018的不在。说明page.posts是不全的,我们应该用网站变量:
<%- css(['/css/archive.css']) %><div class="content"> <% console.log(site)%> <% site.posts.each(function(post){ %> <% console.log(post.title)%> <% }) %>
但是可以看出它似乎没有按照时间排序,前面我们有说过page.posts是Model.js的model对像,在Query.js中给我们提供了个sort方法如下:
所以修改代码如下:
<%- css(['/css/archive.css']) %><div class="content"> <% console.log(site)%> <% site.posts.sort('date').each(function(post){ %> <% console.log(post.title)%> <% }) %>
可以看到已经按时间排序了。
coding……
<%- css(['/css/archive.css']) %><div class="content"> <% var tempYear %> <% var posts = site.posts.sort('date') %> <% posts.each(function(post, i){ %> <% var currentYear = parseInt(date(post.date, 'YYYY')); %> <% if (tempYear != currentYear){ %> <% tempYear = currentYear %> <article> <h3><%- currentYear%></h3> <% } %> <section> <span class="point-time point-yellow"></span> <time datetime="<%- date(post.date, 'YYYY-MM')%>"> <span><%- date(post.date, 'MMMM DD,')%></span> </time> <aside> <p class="things"><%= post.title%></p> <p class="brief"><span class="text-yellow"><%= Object.values(post.categories.data[0])[0] %> </span></p> </aside> </section> <% if (!posts.eq(i + 1) || currentYear != parseInt(date(posts.eq(i + 1).date, 'YYYY'))){ %> </article> <% } %> <% }) %></div>
最后效果如下:
如果想让归档列表按照分类显示不同颜色怎么实现呢?
代码解释和实现方法待续 To be continued……
代码同步上传在github仓库和百度云上,关注公众号Creators创作者回复story009获取。
<%- css(['/css/archive.css']) %><div class="content"> <% var tempYear %> <% var posts = site.posts.sort('date') %> <% posts.each(function(post, i){ %> <% var currentYear = parseInt(date(post.date, 'YYYY')); %> <% if (tempYear != currentYear){ %> <% tempYear = currentYear %> <article> <h3><%- currentYear%></h3> <% } %> <section> <span class="point-time point-yellow"></span> <time datetime="<%- date(post.date, 'YYYY-MM')%>"> <span><%- date(post.date, 'MMMM DD,')%></span> </time> <aside> <p class="things"><%= post.title%></p> <p class="brief"><span class="text-yellow"><%= Object.values(post.categories.data[0])[0] %> </span></p> </aside> </section> <% if (!posts.eq(i + 1) || currentYear != parseInt(date(posts.eq(i + 1).date, 'YYYY'))){ %> </article> <% } %> <% }) %></div>
首先在循环外部定义了两个变量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来展示文章。(不知道看懂没,我觉得应该能看懂了)
首先我们确定颜色是由text-yellow这个class决定的,只要把每个分类名对应一个颜色类就搞定了。可以使用js来实现,当然也可以用css来实现(中文类名也是可以的哦,当然不支持这样做)。这里我采用取巧的方法,顺带也讲个hexo文档中重要的知识点:
我们要用它的关键在这里:
因为我们的language: zh-cn,所以在主题languages文件夹中新建zh-cn.yml,然后在里面输入下内容
color: 技术: blue 生活: green 相册: red vlog: yellow
修改archive.ejs如下:
......<section> <!-- 取巧方法,只认第一个分类 --> <% var category = Object.values(post.categories.data[0])[0]%> <span class="point-time point-<%= __('color.' + category)%>"></span> <time datetime="<%- date(post.date, 'YYYY-MM')%>"> <span><%- date(post.date, 'MMMM DD,')%></span> </time> <aside> <p class="things"><%= post.title%></p> <p class="brief"><span class="text-<%= __('color.' + category)%>"><%= category%> </span></p> </aside></section>......
然后顺带把article.ejs中的返回按钮也给它加上,最终效果如下:
主题开发到这其实还有很多必要的东西未加上去,比如现在首页还没有一个导航能够到archive.ejs页,手机端适配等很多问题。还有一些小功能,比如赞赏、分享等等。想了一下,现在最紧急的应该就是首页导航了,准备用侧边栏。网上找了个侧边栏代码如下:
<nav> <div class="menu-btn"> <div class="line line__1"></div> <div class="line line__2"></div> <div class="line line__3"></div> </div> <div class="sub-menu-btn"> <div class="line line__1"></div> <div class="line line__2"></div> </div> <ul class="nav-links"> <li class="link"> <a href="#">Home</a> </li> <li class="link"> <a href="#">About</a> <ol> <li><a href="#">designers</a></li> <li><a href="#">developers</a></li> </ol> </li> <li class="link"> <a href="#">Work</a> <ol> <li><a href="#">web</a></li> <li><a href="#">graphic </a></li> <li><a href="#">apps </a></li> </ol> </li> <li class="link"> <a href="#">Contact</a> <ol> <li><a href="#">Email</a></li> <li><a href="#">Social</a></li> </ol> </li> <li class="link"> <a href="#">follow me</a> <ol> <li> <a target="_blank" href="https://www.17sucai.com/"> Twitter <i class="fab fa-twitter"></i> </a> </li> <li> <a target="_blank" href="https://www.17sucai.com/"> Codepen <i class="fab fa-codepen"></i> </a> </li> </ol> </li> </ul></nav>
包括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合并压缩成一个,这样会减少请求次数,也优化了页面速度。
加入后效果如下:
代码同步上传在github仓库和百度云上,关注回复story010获取。
上一篇教程我们已经把侧边栏成功的加入到我们的story主题中了,但是该侧边栏还是写死的数据。所以开始把它和我们的主题目录绑定起来。有用过hexo主题的朋友应该知道在config中一般有个menu配置项,用来配置博客的模板页。今天我们就来实现这一过程。
在此之前,有一样东西必须要了解一下(虽然不了解也没事)。那就是config.yml,如果说你学习过其他语言,甚至是开发过一些项目。那么你用的配置文件可能是.json.conf.xml.pro.ini。那么hexo中的.yml又是什么呢?感兴趣的可以学习另一篇文章:yaml基本语法及实现Hexo二级导航栏功能
开始撸代码之前我们要在config中添加sidebar的项:(暂定如下,图标还未考虑好)
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 }, } }
因为post-list中的代码已经够多,而且侧边栏也不算是post-list,所以我们在_partial下新建一个sidebar.ejs文件,把侧边栏代码放进去。然后修改代码如下:(为啥用for in?因为循环的是对象)
<nav> <div class="menu-btn"> <div class="line line__1"></div> <div class="line line__2"></div> <div class="line line__3"></div> </div> <div class="sub-menu-btn"> <div class="line line__1"></div> <div class="line line__2"></div> </div> <ul class="nav-links"> <% var sidebar = theme.sidebar %> <% for (item in sidebar) {%> <li class="link"> <% if (!sidebar[item].submenus) {%> <a href="<%- url_for(sidebar[item].path) %>"><%- item %></a> <% } else { %> <a href="<%- url_for(sidebar[item].path) %>" style="pointer-events: none;"><%- item %></a> <ol> <% for (submenu in sidebar[item].submenus) {%> <li><a href="<%- url_for(sidebar[item].submenus[submenu].path) %>"><%- submenu %></a></li> <% } %> </ol> <% } %> </li> <% } %> </ul></nav>
就里讲下pointer-events: none
pointer-events 更像是JavaScript,它能够:
了解更多参考MDN:pointer-events
侧边栏效果如下:
先在header.ejs中添加fontawesome的css:
<%- css(['/css/main.css', '/css/noscript.css', '/css/sidebar.css', '/css/fontawesome-all.min.css']) %>
接着来到fontawesome官网
点击图标,找到home的class。同理找到其他的图标。
修改config如下:(subsmenu就留给你们练手了)
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 } } }
然后修改sidebar.ejs代码如下:(加了个i标签哦)
<% if (!sidebar[item].submenus) {%> <a href="<%- url_for(sidebar[item].path) %>"><i class="<%= sidebar[item].fa %>"></i><%- item %></a><% } else { %> <a href="<%- url_for(sidebar[item].path) %>" style="pointer-events: none;"><i class="<%= sidebar[item].fa %>"></i><%- item %></a>
最终效果如下!:
代码同步上传在github仓库和百度云上,关注回复story011获取。
本文完|文章链接:都2020了,带你开发hexo主题
|公众号: Creators创作者
|作者:Hojun
|作者博客:https://www.hojun.cn/
好像只有16215版本之后的才可以
鉴于双显卡安装时会卡logo,需要自己修改命令,MacOS+win10+Ubuntu总是会进入紧急模式,而且虚拟机体验非常不好,所以直接启用Win10的子系统,使用起来还是很方便的
方法一: 设置-更新和安全-开发者选项-勾选开发人员模式,接着打开控制面板-程序-启用或关闭Windows功能-勾选“适用于Linux的Windows子系统”前的复选框
方法二:搜索Poweshell,选择以管理员身份运行
输入命令
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
接着输入Y
回车,重启
打开Win10自带的Microsoft Store,选择自己需要的版本下载
单击以下链接会打开每个分发版的 Microsoft Store 页面:
点击win键,找到Ubuntu,点击打开
之后会显示Installing...
等待安装完
之后会要求输入用户名和密码,按照自己的输入即可(ps:输入密码不会显示,输完之后回车即可)
由于默认官方源服务器在国外,访问速度慢,因此将服务器源改为国内的:
阿里云源
: http://mirrors.aliyun.com/ubuntu/清华源
: http://mirrors.tuna.tsinghua.edu.cn/ubuntu/
方法一:修改源列表(/etc/apt/sources.list
)
(1)模板:
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
(2)编辑
所有的源都是这种模式,我们需要改的是红绿部分,红色的为源地址,绿色的为Ubuntu版本代号
源地址为上面给的两个,直接替换掉就行
Ubuntu版本代号通过命令查看:
lsb_release -a
故修改后为
# 阿里云源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
(3)修改源文件sources.list
修改前我们先做个备份,在终端中执行以下命令:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
然后执行下面的命令打开 sources.list 文件,清空里面的内容dG
,把上面我们编辑好的国内的源复制进去,保存后退出ESC,wq
+Enter。
sudo vi /etc/apt/sources.list
(4)更新软件列表和升级
在终端上执行以下命令更新软件列表,检测出可以更新的软件:
sudo apt-get update
在终端上执行以下命令进行软件更新:
sudo apt-get upgrade
方法二:通过命令apt-add-repository
略
对于Linux来说使用shell命令行完全满足大部分场景的使用,但是某些情况还是需要图形界面,比如查看图片、视频,浏览网页,UI设计等,还是需要图形界面的
可以通过执行sudo dpkg-reconfigure locales
选择zh-CN.UTF-8将系统切换为中文环境。
安装桌面、语言包、字体包、输入法等必要软件。
这里选择的是lxde轻量化桌面,个人比较推荐,当然也可以选择xfce,lxqt等其他桌面。
sudo apt install lubuntu-core lxde fcitx fcitx-googlepinyinsudo apt install language-pack-gnome-zh-hanssudo apt install fonts-wqy-zenhei
受限于Linux子系统实现原理,图形界面无法直接输出到显示器。
这里选择vnc远程桌面来解决,当然你也可以选择其他远程桌面方案。
最新版二进制包tigervnc_X86_64https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz,下载解压到根目录即可使用:
wget https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz
sudo tar -C / -zxvf download_file?file_path=tigervnc-1.9.0.x86_64.tar.gz
执行vncserver :0
打开一个远程桌面端口。:0 表示开启5900端口,:1表示5901端口,依次类推。vncserver详细用法见vncserver -h。
Win10打开Windows端vnc客户端,输入IP(可用环回地址)和对于端口号即可进入图形界面。若为第0个端口(即5900)可省略。
通过客户端我们会发现,进入后为黑屏无图像显示。这是因为lxde桌面没启动。
第一次使用vnc会在用户家目录下生成 .vnc目录,里面是vnc的配置文件。通过在~/.vnc/xstartup
末行加上 startlxde&
。
通过vncserver -kill :0;vncserver :0
重启端口即可进入桌面。
安装到此结束,然后就可以愉快地使用了。
]]>※先题干后文
※串联题干:找题目里被反复重复提及的内容——重中之重(中心)
※ 避免选项干扰
标志 mainly about
/discuss
/the best title
/the purpose
方法:
(1)串线:将各段首末句串联成一个整体,注意转折处(普遍适用)
(2)中心句:问题开头的提问,对它的回答,是文章中心独句段
(3)中心词:文中反复高频出现的词(最直观的方法)
标志:“???”(Line,paragragh)most probably means
方法:通过定位好的句子,根据逻辑关系找同义词或反义词
干扰选项特征:字面意思理解
(往往要先排除简单词的常用含义)
(分号、冒号往往表示“=”,即同义)
代词指代:根据上下文,优先指代主题词,是识别同义表达的捷径
标志:example
/case illustrate demonstrate to show to ______
例子本身不重要,重要的是例子所支持的观点。观点一般在例子前,有时也在例子后
干扰选项:就事论事(只关注例子本身)
近年真题,如果掌握例子内容,做题会更加精准(找到共同讨论的话题,重复出现的是重点)
※找作者观点的标志:
now
I,maintain
/hold that
should
could
would
must
及其否定形式 ※ 反复强调的对象也可以是非主干的成分
※ “观其大略,不求甚解”,把握大方向,提升解题效率
标志:What
/how
/why
/because
/because of
/in that
/since
/as
/for
(等)+具体信息
定位好的句子是解题的最为重要的依据,有时结合上下句
选择最佳答案——比较(反复强调的是重点,重点是考点,细节服从主旨)
注意:例证题和细节题都要定位,但是细节题定位点即为答案,而例证题定位 点并非答案,答案在例子前或例子后
标志:attitude
、deem
、consider
、tone
方法:选项词汇归纳
positive
、optimistic
、approval
、supportive
negative
、pessimistic
、disapproval
、critical
、doubtful
、suspicious
、skeptical
、questionable
、objectionable
(令人反感的) neural
、objective
、impartial
、disinterested
uninterested
、unconcerned
、indifferent
(永远不可能成为正确答案) confused
、puzzled
(永远不可能成为正确答案) Biased
、prejudice
、contemptuous
、subjective
(永远不可能成为正确答案) 标志:infer,learnfrom,imply,suggest,conclude
方法:
a. 同义改写——细节/主旨/逻辑
b. 逻辑取反——推理多在转折处
c. 正确答案往往语气缓和:may
※ 词汇量是关键
※ 阅读的本质是逻辑关系:
※ 阅读重点: 感情色彩、不同人物(讨论对象)之间的关系
※ 任何题型都在原文中可以找到依据,找不到依据,往往是方法不恰当
※ 考研阅读理解的答案不是选出来的,而是比较出来的,排除错误选项,根据文章强调的重点选择最佳答案
※ 反复强调的是重点,重点是考点
※ 绝对化用词:
Only must exclusively never all、最高级
一般不选,但如果原文明确出现了这样的绝对化表述,则答案可以入选
一般含may/some这样语气较为缓和的词的选项入选可能性较高
想获取更多笔记,请关注本文原作者微博@轰焦冻家的控控
——————————本文转载自微博@轰焦冻家的控控
局域网内的具体技术:如利用vlan进行业务隔离;通过stp技术来防止环路,保证冗余链路的正常通信;学会使用VRRP技术来实现负载分担以及防止单点故障;利用OSPF协议使得总部和分布的网络能够正常通信;以及运用ACL和NAT对数据流进行控制和去外网通信。
接入层交换机LSW4
创建VLAN
[LSW4]vlan 10
[LSW4-vlan10]vlan 20
[LSW4-vlan20]quit
配置与主机相连的接口为Access并绑定VLAN
[LSW4]int e0/0/1
[LSW4-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[LSW4-Ethernet0/0/1]port link-t a
[LSW4-Ethernet0/0/1]port de vlan 10
[LSW4-Ethernet0/0/1]int e0/0/2
[LSW4-Ethernet0/0/2]port link-t a
[LSW4-Ethernet0/0/2]port de vlan 20
配置与交换机相连的接口为Trunk并允许所有VLAN通过
[LSW4-Ethernet0/0/2]int e0/0/3
[LSW4-Ethernet0/0/3]port link-t t
[LSW4-Ethernet0/0/3]port t allow vlan all
[LSW4-Ethernet0/0/3]int e0/0/4
[LSW4-Ethernet0/0/4]port link-t t
[LSW4-Ethernet0/0/4]port t allow vlan all
[LSW4-Ethernet0/0/4]quit
l 接入层交换机LSW5
与LSW4类似,创建VLAN,设置接口即可
[LSW5]vlan 30
[LSW5-vlan30]vlan 40
[LSW5-vlan40]quit
[LSW5]int e0/0/1
[LSW5-Ethernet0/0/1]port link-t a
[LSW5-Ethernet0/0/1]port de vlan 30
[LSW5-Ethernet0/0/1]int e0/0/2
[LSW5-Ethernet0/0/2]port link-t a
[LSW5-Ethernet0/0/2]port de vlan 40
[LSW5-Ethernet0/0/2]int e0/0/3
[LSW5-Ethernet0/0/3]port link-t t
[LSW5-Ethernet0/0/3]port t allow vlan all
[LSW5-Ethernet0/0/3]int e0/0/4
[LSW5-Ethernet0/0/4]port link-t t
[LSW5-Ethernet0/0/4]port t allow vlan all
[LSW5-Ethernet0/0/4]quit
核心层交换机LSW1
创建VLAN
[LSW1]vlan 10
[LSW1-vlan10]vlan 20
[LSW1-vlan20]vlan 30
[LSW1-vlan30]vlan 40
[LSW1-vlan40]vlan 50
[LSW1-vlan50]quit
与交换机相连接口设为Trunk并允许所有VLAN通过
[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-t t
[LSW1-GigabitEthernet0/0/1]port t allow vlan all
[LSW1-GigabitEthernet0/0/1]int g0/0/3
[LSW1-GigabitEthernet0/0/3]port link-t t
[LSW1-GigabitEthernet0/0/3]port t allow vlan all
[LSW1-GigabitEthernet0/0/3]int g0/0/2
[LSW1-GigabitEthernet0/0/2]port link-t t
[LSW1-GigabitEthernet0/0/2]port t allow vlan all
服务器接入VLAN50,将将与服务器相连的接口设为Access口并绑定VLAN50
[LSW1-GigabitEthernet0/0/2]int g0/0/5
[LSW1-GigabitEthernet0/0/5]port link-t a
[LSW1-GigabitEthernet0/0/5]port de vlan 50
[LSW1-GigabitEthernet0/0/5]quit
给连接路由器的接口绑定VLAN*60,方便配置地址
[LSW1]vlan 60
[LSW1-vlan60]int g0/0/4
[LSW1-GigabitEthernet0/0/4]port link-t a
[LSW1-GigabitEthernet0/0/4]port de vlan 60
[LSW1-GigabitEthernet0/0/4]quit
给VLAN分配IP地址(配置真实网关)
[LSW1]int vlan 10
[LSW1-Vlanif10]ip add 192.168.10.1 24
[LSW1-Vlanif10]int vlan 20
[LSW1-Vlanif20]ip add 192.168.20.1 24
[LSW1-Vlanif20]int vlan 30
[LSW1-Vlanif30]ip add 192.168.30.1 24
[LSW1-Vlanif30]int vlan 40
[LSW1-Vlanif40]ip add 192.168.40.1 24
[LSW1-Vlanif40]int vlan 50
[LSW1-Vlanif50]ip add 192.168.50.1 24
[LSW1-Vlanif50]int vlan 60
[LSW1-Vlanif60]ip add 192.168.60.1 24
[LSW1-Vlanif60]quit
l 核心层交换机LSW2
与LSW1类似,创建VLAN、配置好接口、设置真实网关(与S1地址不同)
[LSW2]vlan 10
[LSW2-vlan10]vlan 20
[LSW2-vlan20]vlan 30
[LSW2-vlan30]vlan 40
[LSW2-vlan40]quit
[LSW2]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-t t
[LSW2-GigabitEthernet0/0/1]port t allow vlan all
[LSW2-GigabitEthernet0/0/1]int g0/0/2
[LSW2-GigabitEthernet0/0/2]port link-t t
[LSW2-GigabitEthernet0/0/2]port t allow vlan all
[LSW2-GigabitEthernet0/0/2]int g0/0/3
[LSW2-GigabitEthernet0/0/3]port link-t t
[LSW2-GigabitEthernet0/0/3]port t allow vlan all
[LSW2-GigabitEthernet0/0/3]quit
[LSW2]vlan 70
[LSW2-vlan70]int g0/0/4
[LSW2-GigabitEthernet0/0/4]port link-t a
[LSW2-GigabitEthernet0/0/4]port de vlan 70
[LSW2-GigabitEthernet0/0/4]quit
[LSW2]int vlan 10
[LSW2-Vlanif10]ip add 192.168.10.2 24
[LSW2-Vlanif10]int vlan 20
[LSW2-Vlanif20]ip add 192.168.20.2 24
[LSW2-Vlanif20]int vlan 30
[LSW2-Vlanif30]ip add 192.168.30.2 24
[LSW2-Vlanif30]int vlan 40
[LSW2-Vlanif40]ip add 192.168.40.2 24
[LSW2-Vlanif40]int vlan 70
[LSW2-Vlanif70]ip add 192.168.70.2 24
[LSW2-Vlanif70]quit
l 客户端开启DHCP
l 交换机LSW1和LSW2上配置DHCP服务
开启DHCP服务
[SW1]dhcp en
Info: The operation may take a few seconds. Please wait for a moment.done.
创建地址池vlan10、vlan20、vlan30、vlan40,其中$代表1~4,网关使用之后配置的虚拟网关
[LSW1]ip pool vlan$0
Info:It’s successful to create an IP address pool.
[LSW1-ip-pool-vlan$0]gateway-list 192.168.10.254
[LSW1-ip-pool-vlan$0]network 192.168.$0.0 mask 255.255.255.0
[LSW1-ip-pool-vlan$0]quit
VLAN绑定地址池
[LSW1]int vlan $0
[LSW1-Vlanif$0]dhcp select global
[LSW1-Vlanif$0]quit
LSW1排除地址
[LSW1-ip-pool-vlan$0]excluded-ip-address 192.168.$0.1 192.168.$0.127
LSW2排除地址
[LSW2-ip-pool-vlan$0]ex 192.168.$0.128 192.168.$0.253
l 汇聚层交换机LSW4、LSW5只需要开启STP即可
[LSW4]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
[LSW5]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
l 核心层LSW1配置
开启STP
[LSW1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
设置LSW1为根桥
[LSW1]stp priority 0
配置VRRP,LSW1是VLAN10、VLAN20的Master,当上层接口错误时,自动降低优先级,让LSW2成为Master
[LSW1]int vlan 10
[LSW1-Vlanif10]vrrp vrid 10 vi 192.168.10.254
[LSW1-Vlanif10]vrrp vrid 10 prio 120
[LSW1-Vlanif10]vrrp vrid 10 track int g0/0/4 reduce 30
[LSW1-Vlanif10]int vlan 20
[LSW1-Vlanif20]vrrp vrid 20 vi 192.168.20.254
[LSW1-Vlanif20]vrrp vrid 20 prio 120
[LSW1-Vlanif20]vrrp vrid 20 track int g0/0/4 re 30
[LSW1-Vlanif20]int vlan 30
[LSW1-Vlanif30]vrrp vrid 30 vi 192.168.30.254
[LSW1-Vlanif30]int vlan 40
[LSW1-Vlanif40]vrrp vrid 40 vi 192.168.40.254
[LSW1-Vlanif40]quit
l 核心层LSW2配置
开启STP,并将优先级设为4096
[LSW2]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
[LSW2]stp prio 4096
配置VRRP,LSW2是VLAN30、VLAN40的Master,当上层接口错误时,自动降低优先级,让LSW1成为Master
[LSW2]int vlan 10
[LSW2-Vlanif10]vrrp vrid 10 vi 192.168.10.254
[LSW2-Vlanif10]int vlan 20
[LSW2-Vlanif20]vrrp vrid 20 vi 192.168.20.254
[LSW2-Vlanif20]int vlan 30
[LSW2-Vlanif30]vrrp vrid 30 vi 192.168.30.254
[LSW2-Vlanif30]vrrp vrid 30 prio 120
[LSW2-Vlanif30]vrrp vrid 30 track int g0/0/4 re 30
[LSW2-Vlanif30]int vlan 40
[LSW2-Vlanif40]vrrp vrid 40 vi 192.168.40.254
[LSW2-Vlanif40]vrrp vrid 40 prio 120
[LSW2-Vlanif40]vrrp vrid 40 track int g0/0/4 re 30
[LSW2-Vlanif40]quit
l LSW1OSPF配置
查看接口IP
[LSW1]dis ip int br
Interface IP Address/Mask Physical Protocol
MEth0/0/1 unassigned down down
NULL0 unassigned up up(s)
Vlanif1 unassigned up down
Vlanif10 192.168.10.1/24 up up
Vlanif20 192.168.20.1/24 up up
Vlanif30 192.168.30.1/24 up up
Vlanif40 192.168.40.1/24 up up
Vlanif50 192.168.50.1/24 up up
Vlanif60 192.168.60.1/24 up up
根据所有IP宣告相应网段
[LSW1]ospf 1
[LSW1-ospf-1]area 0.0.0.0
[LSW1-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]net 192.168.50.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]net 192.168.60.0 0.0.0.255
[LSW1-ospf-1-area-0.0.0.0]quit
[LSW1-ospf-1]qu
l LSW2OSPF配置
与LSW1类似
[LSW2]dis ip int br
Interface IP Address/Mask Physical Protocol
MEth0/0/1 unassigned down down
NULL0 unassigned up up(s)
Vlanif1 unassigned up down
Vlanif10 192.168.10.2/24 up up
Vlanif20 192.168.20.2/24 up up
Vlanif30 192.168.30.2/24 up up
Vlanif40 192.168.40.2/24 up up
Vlanif70 192.168.70.2/24 up up
[LSW2]ospf 1
[LSW2-ospf-1]area 0.0.0.0
[LSW2-ospf-1-area-0.0.0.0]net 192.168.10.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]net 192.168.20.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]net 192.168.30.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]net 192.168.40.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255
[LSW2-ospf-1-area-0.0.0.0]quit
[LSW2-ospf-1]quit
l AR1上ACL+NAT配置
Easy IP:
配置基本ACL并添加规则,允许VLAN10、VLAN30、VLAN50访问外网,VLAN20、40不能访问
[AR1]acl number 2000
[AR1-acl-basic-2000]rule 0 per source 192.168.10.0 0.0.0.255
[AR1-acl-basic-2000]rule 5 per source 192.168.30.0 0.0.0.255
[AR1-acl-basic-2000]rule 10 per source 192.168.50.0 0.0.0.255
[AR1-acl-basic-2000]quit
绑定规则到外网端口
[AR1]int g0/0/2
[AR1-GigabitEthernet0/0/2]nat outbound 2000
静态NAT,将服务器内网地址转为一个专门的公有IP
[AR1-GigabitEthernet0/0/2]nat static global 200.200.200.10 inside 192.168.50.253
[AR1-GigabitEthernet0/0/2]quit
l AR1OSPF配置
配置接口IP
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 192.168.60.100 24
Sep 26 2019 09:54:53-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[AR1-GigabitEthernet0/0/0]int g0/0/1
[AR1-GigabitEthernet0/0/1]ip add 192.168.70.100 24
Sep 26 2019 09:55:16-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[AR1-GigabitEthernet0/0/1]int g0/0/2
[AR1-GigabitEthernet0/0/2]ip add 200.200.200.1 24
Sep 26 2019 09:56:09-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[AR1-GigabitEthernet0/0/2]quit
查看接口地址
[AR1]dis ip int br
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.60.100/24 up up
GigabitEthernet0/0/1 192.168.70.100/24 up up
GigabitEthernet0/0/2 200.200.200.1/24 up up
NULL0 unassigned up up(s)
宣告地址段
[AR1]ospf 1
[AR1-ospf-1]area 0.0.0.0
[AR1-ospf-1-area-0.0.0.0]net 192.168.60.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]net 192.168.70.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]net 200.200.200.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]quit
[AR1-ospf-1]quit
配置到外网的默认路由,并加入到OSPF中
[AR1]ip route-static 0.0.0.0 0.0.0.0 200.200.200.100
[AR1]ospf 1
[AR1-ospf-1]default-route-advertise
[AR1-ospf-1]quit
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 200.200.200.100 24
[AR2-GigabitEthernet0/0/0]int g0/0/1
[AR2-GigabitEthernet0/0/1]ip add 200.200.201.1 24
[AR2-GigabitEthernet0/0/1]quit
PC1能够ping通其他四个VLAN内的主机
PC配置DHCP能够自动获取IP
PC1、PC3和Server1能够ping通外网的主机,PC2和PC4ping通
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
让VLAN10、30内的主机能够访问外网,Server1拥有一个公网IP,以便外网主机能够直接访问Server1
拓扑:
开启DHCP,点应用
配置静态私网IP,方便转换公网
<Huawei>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<LSW2>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.
<Huawei>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<LWS3>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.
<Huawei>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'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'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'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'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<LWS1>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
<Huawei>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<LWR2>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:<Huawei>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<LWR1>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
测试
PC1、PC2、服务器分别pingPC5
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
与上一个实验差不多,将RIP换成OSPF即可
拓扑如下:
去除提示信息,修改交换机名称
<Huawei>sys Enter system view, return user view with Ctrl+Z.[Huawei]un in enInfo: Information center is disabled.[Huawei]sys LWS4
创建VLAN
[LWS4]vlan 10[LWS4-vlan10]vlan 20[LWS4-vlan20]quit
配置接口
[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
启动stp并保存配置
[LWS4]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS4]quit<LWS4>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.
<Huawei>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<LWS5>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.
<Huawei>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<LWS6>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.
创建VLAN
<Huawei>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
配置接口
[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
开启stp并设置为根桥(优先级为0)
[LWS1]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS1]stp prio 0
配置VLAN地址(真实网关)并设置VRRP配置虚拟网关,将S1设置为VLAN10、20的主路由器,当上行接口断了时变为备用路由器
[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
保存配置
<LWS1>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.
OSPF
可以先用dis ip int br
查看所有IP,再宣告网段
[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<LWS1>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.
<Huawei>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<LWS2>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<LWS2>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.
<Huawei>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'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'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<LWS3>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<LWS3>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.
<Huawei>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<LWR1>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.<LWR1>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<LWR1>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.
<Huawei>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<LWR2>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.
<Huawei>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<LWR3>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.
Ping
S1或S2
S4或S5
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
《逆水寒》是由杭州网易雷火科技有限公司开发的一款武侠题材的电脑客户端游戏,属于大型多人在线角色扮演游戏,以温瑞安《四大名捕》、《说英雄谁是英雄》、《神州奇侠》三大系列小说为游戏背景。该作于2018年6月29日开启不限号不删档内测,预计于2018年内公测。
《逆水寒》有着较为优秀的画面表现效果和较真实的“江湖”氛围感。该作引入TressFX发丝技术,使游戏中的体积雾更加细致真实;在物理表现上使用了Havok引擎;在光照表现上该作是首款采用Enlighten全局光照技术的国产游戏。此外,在游戏的收费模式上,经过玩家票选该作将采用时间点卡收费。
———-引自搜狗百科
说实话,这游戏背景超级好看的,敬请欣赏:
以上图片来源于网络
]]>配置RIP
说明:
1.交换机和三层交换机配置RIP
2.左边静态地址、右边DHCP
3.左边除了DHCP,昨天的都配上
IP规划:
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
静态IP,手动配置
DHCP,动态获取IP地址
只需要配置接口、vlan即可 S5也是
命名
<Huawei>sys Enter system view, return user view with Ctrl+Z.[Huawei]sys LWS4
删除提示信息
[LWS4]un in enInfo: Information center is disabled.
创建VLAN
[LWS4]vlan 10[LWS4-vlan10]vlan 20[LWS4-vlan20]quit
接口配置
[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.
保存配置
[LWS4]quit<LWS4>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.
<Huawei>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.
<Huawei>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
<Huawei>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
stp
[LWS1]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.[LWS1]stp prio 0
VLAN的IP及VRRP
[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
S1是VLAN10和VLAN20主R,设置接口监听,与路由器连接的接口有问题,则优先级降30,让S2为主R
[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
RIP,可以先用
dis ip int brief
查看所有IP,然后添加
[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
<Huawei>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
<Huawei>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'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'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
<Huawei>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
<Huawei>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
<Huawei>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
PC互ping
S4或S5
dis stp brief
S1或S2
dis vrrp brief
接着shutdown
S1的上层端口
Master变为backup
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
实验目的:DHCP中继
配置:
拓扑如下:
打开DHCP,启用接口
<H3C>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.
[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.
[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.
[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.
测试
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
1、Vrrp
2、Stp
3、能用DHCP自动获取IP
4、能相互ping通
拓扑如下
<Huawei>sys Enter system view, return user view with Ctrl+Z.[Huawei]sys LWS3
去除提示信息
[LWS3]undo info-center enable Info: Information center is disabled.
创建VLAN
[LWS3]vlan 10[LWS3-vlan10]vlan 20[LWS3-vlan20]quit
接口配置
[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
开启stp
[LWS3]stp mode stpInfo: This operation may take a few seconds. Please wait for a moment...done.
保存配置
<LWS3>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.
Enter system view, return user view with Ctrl+Z.
[Huawei]sys LWS4
[LWS4]un in en
Info: Information center is disabled.
[LWS4]vlan 30
[LWS4-vlan30]vlan 40
[LWS4-vlan40]quit
[LWS4-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[LWS4-Ethernet0/0/3]port link-t a
[LWS4-Ethernet0/0/3]port de vlan 30
[LWS4-Ethernet0/0/3]quit
[LWS4]int e0/0/4
[LWS4-Ethernet0/0/4]un sh
Info: Interface Ethernet0/0/4 is not shutdown.
[LWS4-Ethernet0/0/4]port link-t a
[LWS4-Ethernet0/0/4]port de vlan 40
[LWS4-Ethernet0/0/4]quit
[LWS4]int e0/0/1
[LWS4-Ethernet0/0/1]un sh
Info: 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]quit
[LWS4]int e0/0/2
[LWS4-Ethernet0/0/2]un sh
Info: 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 stp
Info: This operation may take a few seconds. Please wait for a moment…done.
<Huawei>sysEnter system view, return user view with Ctrl+Z.[Huawei]sys LWS1
去除提示信息
[LWS1]un in enInfo: Information center is disabled.
创建vlan
[LWS1]vlan 10[LWS1-vlan10]vlan 20[LWS1-vlan20]vlan 30[LWS1-vlan30]vlan 40
设置接口
[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
配置STP
`
[LWS1]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
[LWS1]stp priority 0
> 配置vlan地址(网关),vrrp
[LWS1]int vlanif10
[LWS1-Vlanif10]ip add 192.168.10.1 255.255.255.0
[LWS1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[LWS1-Vlanif10]vrrp vrid 10 prio 120
[LWS1-Vlanif10]int vlanif20
[LWS1-Vlanif20]ip add 192.168.20.1 255.255.255.0
[LWS1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
[LWS1-Vlanif20]vrrp vrid 20 prio 120
[LWS1-Vlanif20]int vlanif30
[LWS1-Vlanif30]ip add 192.168.30.1 255.255.255.0
[LWS1-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254
[LWS1-Vlanif30]int vlanif40
[LWS1-Vlanif40]ip add 192.168.40.1 255.255.255.0
[LWS1-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254
[LWS1-Vlanif40]quit
> 配置DHCP
[LWS1]dhcp en
Info: The operation may take a few seconds. Please wait for a moment.done.
[LWS1]ip pool vlan10
Info:It’s successful to create an IP address pool.
[LWS1-ip-pool-vlan10]gateway-list 192.168.10.254
[LWS1-ip-pool-vlan10]network 192.168.10.0 mask 255.255.255.0
[LWS1-ip-pool-vlan10]quit
[LWS1]ip pool vlan20
Info:It’s successful to create an IP address pool.
[LWS1-ip-pool-vlan20]gateway-list 192.168.20.254
[LWS1-ip-pool-vlan20]network 192.168.20.0 mask 255.255.255.0
[LWS1-ip-pool-vlan20]excluded-ip-address 192.168.20.1 192.168.20.127
[LWS1-ip-pool-vlan20]quit
[LWS1]ip pool vlan30
Info:It’s successful to create an IP address pool.
[LWS1-ip-pool-vlan30]gateway-list 192.168.30.254
[LWS1-ip-pool-vlan30]network 192.168.30.0 mask 255.255.255.0
[LWS1-ip-pool-vlan30]excluded-ip-address 192.168.30.1 192.168.30.127
[LWS1-ip-pool-vlan30]quit
[LWS1]ip pool vlan40
Info:It’s successful to create an IP address pool.
[LWS1-ip-pool-vlan40]gateway-list 192.168.40.254
[LWS1-ip-pool-vlan40]network 192.168.40.0 mask 255.255.255.0
[LWS1-ip-pool-vlan40]excluded-ip-address 192.168.40.1 192.168.40.127
[LWS1-ip-pool-vlan40]quit
[LWS1]int vlan 10
[LWS1-Vlanif10]dhcp select global
[LWS1-Vlanif10]int vlan 20
[LWS1-Vlanif20]dhcp select global
[LWS1-Vlanif20]int vlan 30
[LWS1-Vlanif30]dhcp select global
[LWS1-Vlanif30]int vlan 40
[LWS1-Vlanif40]dhcp select global
[LWS1-Vlanif40]quit
### S2:
Enter system view, return user view with Ctrl+Z.
[Huawei]sys LWS2
[LWS2]un in en
Info: Information center is disabled.
[LWS2]vlan 10
[LWS2-vlan10]vlan 20
[LWS2-vlan20]vlan 30
[LWS2-vlan30]vlan 40
[LWS2-vlan40]quit
[LWS2]int g0/0/1
[LWS2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[LWS2-GigabitEthernet0/0/1]port link-t t
[LWS2-GigabitEthernet0/0/1]port t allow vlan all
[LWS2-GigabitEthernet0/0/1]quit
[LWS2]int g0/0/2
[LWS2-GigabitEthernet0/0/2]un sh
Info: 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 sh
Info: 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]quit
[LWS2]stp mode stp
Info: This operation may take a few seconds. Please wait for a moment…done.
[LWS2]stp prio 4096
[LWS2]int vlanif10
[LWS2-Vlanif10]ip add 192.168.10.2 24
[LWS2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
[LWS2-Vlanif10]int vlanif20
[LWS2-Vlanif20]ip add 192.168.20.2 24
[LWS2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
[LWS2-Vlanif20]int vlanif30
[LWS2-Vlanif30]ip add 192.168.30.2 24
[LWS2-Vlanif30]vrrp vrid 30 virtual-ip 192.168.30.254
[LWS2-Vlanif30]vrrp vrid 30 prio 120
[LWS2-Vlanif30]int vlanif40
[LWS2-Vlanif40]ip add 192.168.40.2 24
[LWS2-Vlanif40]vrrp vrid 30 virtual-ip 192.168.40.254
[LWS2-Vlanif40]un vrrp vrid 30 virtual-ip 192.168.40.254
[LWS2-Vlanif40]vrrp vrid 40 virtual-ip 192.168.40.254
[LWS2-Vlanif40]vrrp vrid 40 prio 120
[LWS2-Vlanif40]quit
[LWS2]dhcp en
Info: The operation may take a few seconds. Please wait for a moment.done.
[LWS2]i pool vlan10
Info:It’s successful to create an IP address pool.
[LWS2-ip-pool-vlan10]gateway-list 192.168.10.254
[LWS2-ip-pool-vlan10]network 192.168.10.0 mask 255.255.255.0
[LWS2-ip-pool-vlan10]ex 192.168.10.128 192.168.10.253
[LWS2-ip-pool-vlan10]quit
[LWS2]i pool vlan20
Info:It’s successful to create an IP address pool.
[LWS2-ip-pool-vlan20]gateway-list 192.168.20.254
[LWS2-ip-pool-vlan20]network 192.168.20.0 mask 255.255.255.0
[LWS2-ip-pool-vlan20]ex 192.168.20.128 192.168.20.253
[LWS2-ip-pool-vlan20]quit
[LWS2]i pool vlan30
Info:It’s successful to create an IP address pool.
[LWS2-ip-pool-vlan30]gateway-list 192.168.30.254
[LWS2-ip-pool-vlan30]network 192.168.30.0 mask 255.255.255.0
[LWS2-ip-pool-vlan30]ex 192.168.30.128 192.168.30.253
[LWS2-ip-pool-vlan30]quit
[LWS2]i pool vlan40
Info:It’s successful to create an IP address pool.
[LWS2-ip-pool-vlan40]gateway-list 192.168.40.254
[LWS2-ip-pool-vlan40]network 192.168.40.0 mask 255.255.255.0
[LWS2-ip-pool-vlan40]ex 192.168.40.128 192.168.40.253
[LWS2-ip-pool-vlan40]quit
[LWS2]
[LWS2]int vlan 10
[LWS2-Vlanif10]dhcp select global
[LWS2-Vlanif10]int vlan 20
[LWS2-Vlanif20]dhcp select global
[LWS2-Vlanif20]int vlan 30
[LWS2-Vlanif30]dhcp select global
[LWS2-Vlanif30]int vlan 40
[LWS2-Vlanif40]dhcp select global
[LWS2-Vlanif40]quit`
PC:
Ipconfig查看IP然后Ping另一台PC
S3或S4
dis stp brief
S1或S2
dis vrrp brief
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
很长的一部著作,算是看过最长的了,很接地气的描写,故事一句话概括的话,应该算是:平凡青年的奋斗史。所以是不是应该把书名改为奋斗呢?所以是不是有很多这样的书呢?所以这为什么能让那么多人为之热血呢?我是带着崇拜并质疑的心态来阅读的,似乎没有能迅速找到答案,所以我便闭卷考试似的来回忆,梳理,总结,感悟,看能不能找到答案。
回忆三本书的故事,主人公应该是孙家一行人,衍生出来的左右旁支,亲朋好友也生存于其中;应该是黄土高原的背景,时间开始是三年自然灾害之后历时文革,改革开放这样的时间段,孙家算是几代贫农,但为人忠厚,在这样的村子里和很多贫下中农一样的活着,但是这样的孙玉厚,当家人,有着不一样的眼光,就是培养了自己的弟弟和两子一女上学,弟弟 后来成为了村里的党政管理人员,但对大哥确实不够感恩。
大哥孙少安中考考了第三,但是家里无力承担学费,便回家务农,并供养弟弟孙少平和妹妹孙兰香读书,自己成家后也承包过土地,开砖厂,扩张时倒闭了而后又东山再起,育有一子一女,老婆在日子红火了以后得了肺癌。
孙少平高中毕业,识得家中苦,也在高中自卑过,也有爱慕的人,也受田晓霞的影响开始大量的学习和阅读,最后回村教过书,务过农,不安平淡的出去闯荡,做过苦力,兼职过老师,最后扎根煤矿,他与晓霞的爱情放在现在看来是纠结的,但最后影响他最深的人也在一次洪水中,死去。
孙兰香大学毕业;天体物理学,说实话有点跳戏到三体;算是家里保护的最好的人,洗去了农村的习性,最后有好的男朋友。
其他人物有这么几个记忆深刻:
孙少安的青梅竹马,互相爱慕却最终没走在一起,嫁给了门当户对的好人家却过着寡妇的生活,在丈夫残疾后又毅然肩负家庭;润叶的朋友:已婚妇女却爱上了诗人,最后离婚;
田家的书记;弟弟先是仕途不得志而后受省里重用提拔,开启了黄原地区改革开放的新篇章;而后调任直辖市一把手;哥哥一直是村里的老八股,老谋深算不得善终;
孙少平相关联人:金波,文艺兵,因为爱上藏族姑娘,被强制退伍,八年后再去寻找,已物是人非;金波妹妹,突然结尾就爱上了少平,但是少平没有接受;师傅:死了但是对少平很好,师娘:对少平很好,少平也担负他们孤儿寡母的生活照料;第一个雇佣着:给少平迁户口,想着做女婿;
在其他的就想不起了,简单介绍完才发现写了好多,没办法,三本嘛,读完这本书有一个下意识的感觉,这本书可不那么平凡哩,因为有几处真的看着人身体发热;少安娶媳妇,少平想出去见识;少平有想法但是碍于现实做出的一段反思;少平后期的经历从搬运工到煤矿工就;润叶的一段故事;这些都是下意识的身体发热,平凡的话怎么会发热呢?后来我思考了下原因
1、婚恋:其实算算自己也不小了,看少安那段忽然让人觉得婚姻就是一个很简单但是又很幸福的事情,都让人很向往了,没有彩礼,家里一贫如洗的取了个好媳妇儿回来,多么美好,我也渴求,我也希望,但是放在这样的时代,真的是做不到啊,如果真的门当户对就好了么?这是润叶出现了,她的婚姻,其实让我很惊讶,本能觉得这女娃有点作死,好日子不过,苦了就知道相夫教子了,这样看来这婚结也难,不结也难。后来想想,老天爷看着累,让你好你怎么找都好,不让你找,怎么找都找不好;
2、当思想过于丰富,现实过于困难的时候,特别喜欢少平那一段自我剖析,八五后的我也是会有这样的想法,自认为自己有的地方很优秀,但是无法施展,这必然是要找个迁怒者的,可能是父母辈,可能是对于现实的怒吼,也可能是对自己的否定,由此长期陷入一个困局,就像DNA结构一样,螺旋延伸,但是少安他用他的肩膀,一身的伤痕,黝黑的皮肤以及最后脸上的疤痕证明了,也许生活还会一直平凡下去,但是,心不能死;因为一切都还会继续,不管是好的还是不好的方向;
3、少平的发家史,其实这段我是有过体会的,虽然没有那么刻骨,但是真心喜欢那种在苦难中咬碎牙齿也要把事情办好的过程,回想过去一年,还是自己放松了,我想我会找回那种感觉得,就在现在,从现在开始;
4、少安,少平的为人,你凭啥能获得老天的眷顾呢?还是好好为人吧,希望自己还是能多一些怜悯心,多一些责任心,多一些狠心;怜悯心要真正的最苦难有所觉悟,才会在即便是被骗的时候,依然想着好;责任心,解决自己的经济困难这是最基本的,因为你不需要拖累别人,解决自己的父母环境问题也是基本的,我希望未来我的父母能够在退休后想做点什么就做点什么,而不是日日背负着我的房贷;对亲朋好友的责任心,一世为人,为亲戚,为朋友,还是挺难得的,能帮还是帮一下,前提是我得有能力帮才行对吧;这达到这个层次我觉得跟马斯洛需求理论不谋而合;狠心,怕是我最难得解决的问题,对外不强硬,一方面本身是个性的棉条另一方面是冷感;该有的问题必须要解决,这是逃脱不掉的,不该有的问题,不要自己揽上身,怕是事多心烦哩;
梳理完这些与我学习到的东西我在思考,这本书和绝大多数励志书有什么不一样?又或者说,它凭什么得到如此高的推崇;是更贴近我们这个时代?并不是吧,毕竟文革后的改革开放那是做点事也能成的环境,我们羡慕着呢;是主人公历经九九八十一难成为了牛逼哄哄的任务?并不是吧,感觉书都没写完,对于少安来说妻子得了癌症,事业略有起色,建了个学校,对于少平,美女投怀送抱不要,心爱的人死了,自己死里逃生,励志扎根煤矿,可以调回到家乡的机会也不要,很难想象历尽艰辛之仍是艰辛是多好的结局;
答案似乎有了:在经过一千二百多页的跋涉,所有的人该生活的还是继续生活,这里没有霸道总裁,也没有天降神兵,生活还是继续,苦逼也还是继续,在经历过艰难困苦后,生活所带来的依然是艰辛,依然是困苦,但是都过来了,所以也都习惯了,所以也都成长了;
这本书似乎没有写完了,又似乎早就该写完了,我想这种真实很贴近我们,而少安的生活似乎离我们远了点,但是少平则应该成为我们的男神。
最后想写一点这个书里我不是很喜欢的一处处理,那就很多时候作者跳出了故事本身,开始用大篇幅的教育词句来进行教育,我想说,我认为的这些处有很多,我不喜欢, 经典的语句或者说直击人心的感悟应该有,但是过于泛滥了我的路遥同志,有时候黄图上的一轮明月和满目黄沙,要比很多语句都更来的——有力度。
]]>在实验二的基础上(VLAN10、20、30、40内的主机之间互ping成功)实现用DHCP给各vlan内主机自动分配地址
由于在上一个实验的基础上,因此只需要配置四个PC和最上面的交换机S0即可
使用DHCP,启用接口
配置DHCP
`
System View: return to User View with Ctrl+Z.
[LwS0]dhcp enable
[LwS0]dhcp server ip-pool vlan10
[LwS0-dhcp-pool-vlan10]network 192.168.10.1 mask 255.255.255.0
[LwS0-dhcp-pool-vlan10]gateway-list 192.168.10.1
[LwS0-dhcp-pool-vlan10]qui
[LwS0]dhcp server ip-pool vlan20
[LwS0-dhcp-pool-vlan20]network 192.168.20.1 mask 255.255.255.0
[LwS0-dhcp-pool-vlan20]gateway-list 192.168.20.1
[LwS0-dhcp-pool-vlan20]quit
[LwS0]dhcp server ip-pool vlan30
[LwS0-dhcp-pool-vlan30]network 192.168.30.1 mask 255.255.255.0
[LwS0-dhcp-pool-vlan30]gateway-list 192.168.30.1
[LwS0-dhcp-pool-vlan30]quit
[LwS0]dhcp server ip-pool vlan40
[LwS0-dhcp-pool-vlan40]network 192.168.40.1 mask 255.255.255.0
[LwS0-dhcp-pool-vlan40]gateway-list 192.168.40.1
[LwS0-dhcp-pool-vlan40]quit
> <font color = "blue">保存配置</font>
[LwS0]quit
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
flash:/startup.cfg exists, overwrite? [Y/N]:y
Validating file. Please wait…
Saved the current configuration to mainboard device successfully.`
查看各个PC的ip
然后ping另一台PC,能ping通即可
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
Vlan间通信:
VLAN10、20、30、40内的主机之间互ping成功
拓扑图如下:
主机IP:
PC1: 192.168.10.100/24
PC2: 192.168.20.100/24
PC3: 192.168.30.100/24
PC4: 192.168.40.100/24
VLANIP规划:
VLAN10: 192.168.10.1/24
VLAN20: 192.168.20.1/24
VLAN30: 192.168.30.1/24
VLAN40: 192.168.40.1/24
配置好IP地址,掩码,网关(网关是VLAN的IP)
命名
`
System View: return to User View with Ctrl+Z.
[H3C]sys LWS0
>创建四个vlan
[LWS0]vlan 10
[LWS0-vlan10]quit
[LWS0]vlan 20
[LWS0-vlan20]vlan 30
[LWS0-vlan30]vlan 40
[LWS0-vlan40]quit
> 给vlan分配IP
[LWS0]int vlan 10
[LWS0-Vlan-interface10]ip add 192.168.10.1 255.255.255.0
[LWS0-Vlan-interface10]quit
[LWS0]int vlan 20
[LWS0-Vlan-interface20]ip add 192.168.20.1 255.255.255.0
[LWS0-Vlan-interface20]int vlan 30
[LWS0-Vlan-interface30]ip add 192.168.30.1 255.255.255.0
[LWS0-Vlan-interface30]int vlan 40
[LWS0-Vlan-interface40]ip add 192.168.40.1 255.255.255.0
[LWS0-Vlan-interface40]quit
>接口设为trunk并允许所有vlan通过
[LWS0]int g1/0/1
[LWS0-GigabitEthernet1/0/1]port link-type trunk
[LWS0-GigabitEthernet1/0/1]port trunk permit vlan all
[LWS0-GigabitEthernet1/0/1]no sh
[LWS0-GigabitEthernet1/0/1]int g1/0/2
[LWS0-GigabitEthernet1/0/2]no sh
[LWS0-GigabitEthernet1/0/2]port link-ty t
[LWS0-GigabitEthernet1/0/2]port t p vlan all
#### 3、左边交换机S1> 命名
System View: return to User View with Ctrl+Z.
[H3C]sys LWS1
创建vlan
[LWS1]vlan 10
[LWS1-vlan10]vlan 20
[LWS1-vlan20]quit
> 与交换机相连的接口设为trunk,允许所有vlan通过
[LWS1-GigabitEthernet1/0/1]no sh
[LWS1-GigabitEthernet1/0/1]port link-ty t
[LWS1-GigabitEthernet1/0/1]port t p vlan all
[LWS1-GigabitEthernet1/0/1]quit
>下面两个接口设为access
[LWS1]int g1/0/2
[LWS1-GigabitEthernet1/0/2]port link-ty a
[LWS1-GigabitEthernet1/0/2]port a vlan 10
[LWS1-GigabitEthernet1/0/2]int g1/0/3
[LWS1-GigabitEthernet1/0/3]no sh
[LWS1-GigabitEthernet1/0/3]port link-ty a
[LWS1-GigabitEthernet1/0/3]port a vlan 20
[LWS1-GigabitEthernet1/0/3]quit
#### 4、右边交换机S2
[LWS2]vlan 30
[LWS2-vlan30]vlan 40
[LWS2-vlan40]quit
[LWS2]int g1/0/1
[LWS2-GigabitEthernet1/0/1]port link-ty t
[LWS2-GigabitEthernet1/0/1]port t p vlan all
[LWS2-GigabitEthernet1/0/1]quit
[LWS2]int g1/0/2
[LWS2-GigabitEthernet1/0/2]port link-ty a
[LWS2-GigabitEthernet1/0/2]port a vlan 30
[LWS2-GigabitEthernet1/0/2]int g1/0/3
[LWS2-GigabitEthernet1/0/3]port link-ty a
[LWS2-GigabitEthernet1/0/3]port a vlan 40
[LWS2-GigabitEthernet1/0/3]quit`
其他的网上有详细的配置,因此只给出方法
1、如果只有两个VLAN,那么可以在交换机端口设置trunk的本征VLAN,自行去标签
多个VLAN的话设成Hybrid口,用untag撕去标签
2、通过路由接口
3、通过单臂路由
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
- 命名R、2S为自己姓名首字母
- 给设备配置时间
- PC能够Ping通R
- Host能telnet路由器
单机图示图标,新建工程,自己命名选择路径保存
从左边选择设备,拖入操作区,使用GE线缆将设备连接起来,连接Host的时候注意选择有线网卡
在真机环境中打开命令提示符,输入ipconfig
获得刚刚新建的网卡IP
图示显示169…未分配地址,打开网络管理界面,右击Vbox…网卡
属性–找到Internet协议版本4(TCP/IPv4),双击后配置静态IP
禁用-启用该网卡,再次输入ipconfig
查看IP地址
启动所有设备
右击PC,选择配置,输入相关参数,启用接口
Ctrl+C退出自动配置,按enter继续
<H3C>system-viewSystem View: return to User View with Ctrl+Z.[H3C]sysname LWR
[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
[LWR]telnet server enable[LWR]user-interface vty 0 4[LWR-line-vty0-4]authentication-mode none[LWR-line-vty0-4]user level-5
真机到控制面板中选择程序,启用服务,勾选Telnet Client,确定,开启telnet功能
S1:
Ctrl+C enter
<H3C>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
S2:
Ctrl+C enter
<H3C>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
System View: return to User View with Ctrl+Z.
[LWR]clock p
[LWR]clock protocol none
[LWR]quit
7、保存
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please 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.
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
下载下面的文件
链接:https://pan.baidu.com/s/13kzRjgJqHXOsvRK54Waz1w 密码:mqh3
双击HCL_V2.1.1_Setup.exe开始安装,安装过程中注意不要勾选VBox。
安装完成之后双击VirtualBox-4.2.4-81684-Win.exe,没什么注意事项,一直下一步,点允许即可
右击HCL,选择属性
点击兼容性,按图修改
点击更改高DPI设置,勾选如图复选框
之后双击打开即可
选择两个PC测试,VMbox会相应生成设备
点击启动按钮
稍等一会右击vPC,点击配置,输入相关参数,点击启用,这时接口状态显示为ADM
勾选接口管理下方的启用选项
将两个都配置好,接口状态变为UP
双击PC,进入命令行,ping对方IP,能ping通,软件安装和使用都不会有问题了
文章汇总:
HCL的安装和使用 |
ping通及Telnet |
VLAN间通信 |
DHCP配置 |
DHCP中继 |
STP及VRRP配置 |
RIP配置 |
OSPF配置 |
ACL+NAT配置 |
使用eNSP搭建企业网络 |
程序(Program) = 算法(Algorithms) + 数据结构(Data Structure)
数据结构需要使用程序语言来描述,比如C/C++
以下是C/C++的第一个程序
#include <stdio.h> // 预处理指令#include <stdlib.h> // 将stdio.h和stdlib.h引入程序,stdio中包含标准输入输出函数 stdlib为标准库头文件,一些宏和一些函数如malloc()、system()等需要用到 在C++中为cstdio、cstdlibint main() // main函数函数头{ // {...}为函数体 printf("Hello World"); // 打印语句 return 0; // 函数返回0,0称为函数返回值}// 注释:单行注释使用"//",块注释使用"/* */",Java中文档注释使用"/** */"
#include <iostream>using namespace std; // 使用std这个命名空间,函数体中使用cout、cin就不需要写成std::cout、std::cin的格式了int main(){ cout << "Hello World" <<endl; return 0;}//main(int argc,char *argv[])--带参数的main函数 argc代表命令行参数的个数,argv[0]存放的是命令,argv[i]存放的是命令行中的第i个参数(i>=1)eg:ping 192.168.1.1 argc=1;argv[0]="ping";argv[1]="192.168.1.1";
C/C++程序运行:源程序test.c(.cpp)-编译
->二进制文件test.obj-连接
->test.exe(或其他可执行文件)-运行
->运行成功或失败
常量
常量
是程序运行过程中值不能改变的量(1)整型常量
:如10000,0,-345(2)实型常量
:123.4,0.0,-9.79,12.34e3(12.34x10^3)(3)字符常量
:普通字符如’a’,’Z’,’3’,’?’及转义字符\n,\t等(4)字符串常量
:”hello”,”12346”(5)符号常量
:不占内存
#define PI 3.1415926
const float PI = 3.14159f;
变量
变量
代表一个有名字的、具有特定属性的一个存储单元,用来存放变量的值,变量的值是可以改变的。变量必须先定义,后使用。变量定义
:
<数据类型> <变量名1>[,<变量名2>,···];
如int a;
char c;
double b;
bool isE;
等变量名
使用标识符来标识。用来对变量、符号常量名、函数、数组、类型等命名的有效字符徐磊统称为标识符
。标识符由大小写字母、数字字符和下划线组成,且第一个字符不能为数字,还有用户定义的标识符不能和系统保留关键字同名。
在同一个作用域中不能有两个或两个以上相同的变量名变量赋值和初始化
(1)定义后赋值
int x,y;x = 8;y = x;
(2)定义的同时赋值
int n = 1;double d = 1.25;char c = 'a';
(3)定义多个变量时单独赋一个
int n1, n2 = 4, n3;
(4)C++中
int n1(1), n2(4), n3; //定义三个整型变量n1、n2、n3,且赋初值n1为1、n2为4
保留关键字
asm
auto
break
case
catch
char
class
const
continue
default
delete
do
double
else
enum
extern
float
for
friend
goto
if
inline
int
long
new
operator
private
protected
public
register
return
short
signed
sizeof
static
struct
switch
template
this
throw
try
typedef
union
unisigned
virtual
void
volatile
while
数据类型
使用sizeof()
获取数据类型字宽
运算符和表达式
算术运算符
:四则运算(+
、-
、*
、/
),求余(%
),自增(++
),自减(--
)关系运算符
:大等小(>
、>=
、==
、<
、<=
),不等(!=
)逻辑运算符
:与或非(&&
、||
、!
)位运算符
:按位与(&
)、按位或(|
)、按位异或(^
)、取反(~
)、左移(<<
)、右移(>>
)赋值运算符
:赋值(=
),扩展(+=
、-=
、/=
、*=
、%=
···)条件运算符
:(? :
)逗号运算符
:(,
)指针运算符
:(*
、&
)求字节数运算符
:(sizeof()
)强制类型转换运算符
:((<type>)
)成员运算符
:(.
、->
)下标运算符
:([]
)其他
:函数调用(()
)注意运算符的优先级,运算顺序
运算符表达式
–用算术运算符和括号将运算对象连接起来的,符合C/C++语法规则的式子语句
if()···else···
for()···
、while()···
、do···while();
continue
break
switch()
return
goto
printf("1");
max(1,2);
a=3;
i++;
;
只有一个分号,什么也不做{}
把语句和声明括起来,又称语句块函数体包含声明部分和执行部分,执行部分是由语句组成的,语句的作用是向计算机系统发出操作指令,要求执行相应的操作。
input:
scanf("%c",&s);
a = getchar();
gets();
std::cin >> a;
output:
printf("%s",s);
putchar(a);
puts();
std::cout << a <<endl;
格式控制
%d
、%i
–十进制整型%o
–八进制整型%x
、%X
–十六进制数%u
–无符号型%c
–字符%s
–字符串%f
–6位小数单双精度%e
、%E
–指数形式的实型%g
、%G
–自动选择%f %e
%l
–长整型,加在d、o、x、u前
%-m.nf
–向左靠齐,m个宽度,n为小数的实数顺序结构
在顺序结构中,各语句是自上而下的顺序执行的,执行完上一个语句就自动执行下一个语句,是无条件的,不需要作任何判断。是最简单的程序结构。
选择(分支)结构
if语句 选择结构
if(表达式) 语句1[else 语句2]/*此处的表达式主要为:关系表达式 (a>b)==c逻辑表达式 !a&&(b||c)条件表达式 a>b ? (max=a) : (max=b)*/
注意if语句的嵌套
switch语句 多分支选择结构
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标号可以共用一组执行语句*/
循环结构
while(表达式){ 循环体}/* 先判断表达式,后执行循环语句 */
do{ 循环体}while(表达式);/* 先无条件执行循环体,然后判断循环条件是否成立。因此最少需要执行循环体一次。 */
for(循环变量赋初值;循环条件;循环变量增值){ 循环体}/* 表达式可以省,但是分号要保留 */
注意分析即可
continue
:结束本次循环break
:终止整个循环
数组
是相同类型的元素的有序集合。每个元素在内存中占用相同大小的内存单元,这些内存单元在内存空间中都是连续存放的。
一维数组
类型 数组名[常量表达式];
比如int a[10];
这是一个含有a[0]到a[9]十个元素的名字为a的数组引用数组名[下标]
初始化
int a[5] = {0,1,2,3,4};
int a[5] = {0,1};
int a[5] = {0,0,0,0,0};
或int a[5] = {0};
int a[] = {0,1,2,3,4};
二维数组
类型 数组名[常量表达式1][常量表达式2];
比如float a[3][4],b[5][10];
,C中存放数组是按行优先的
数组名[下标][下标]
int a[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
int a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12};
int a[3][4] = {{1},{5},{9}};
int a[][4] = {1,2,3,4,5,6,7,8,9,10,11,12};
int a[][4] = {{0,0,3},{},{0,10}};
字符数组
string类
字符串处理函数
上一个文章有提到过修改
scaffolds/post.md
达到修改博文模板的作用
--- title: {{ title }} #文章标题,可以和文件名不同date: {{ date }} #发布时间categories: #分类 - category - subcategorytags: #标签 - tag1 - tag2---
前面博客中还提到过插入图片的,这里总结一下
- 下面这个要填写你使用github.io访问博客的地址
# URL## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'url: http://wallleap.github.io
这个需要改成true
post_asset_folder: true
安装插件
npm install hexo-assert-folder --save
但是这个插件的内容需要修改【不然可能会出Bug】
打开/node_modules/hexo-asset-image/index.js,将内容更换为下面的代码
'use strict';var cheerio = require('cheerio');// 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('.');hexo.extend.filter.register('after_post_render', function(data){var config = hexo.config;if(config.post_asset_folder){var link = data.permalink;if(version.length > 0 && Number(version[0]) == 3)var beginPos = getPosition(link, '/', 1) + 1;elsevar beginPos = getPosition(link, '/', 3) + 1;// In hexo 3.1.1, the permalink of "about" page is like ".../about/index.html".var endPos = link.lastIndexOf('/') + 1;link = link.substring(beginPos, endPos);var toprocess = ['excerpt', 'more', 'content'];for(var i = 0; i < toprocess.length; i++){var key = toprocess[i];var $ = cheerio.load(data[key], {ignoreWhitespace: false,xmlMode: false,lowerCaseTags: false,decodeEntities: false});$('img').each(function(){if ($(this).attr('src')){// For windows style path, we replace '\' to '/'.var src = $(this).attr('src').replace('\\', '/');if(!/http[s]*.*|\/\/.*/.test(src) &&!/^\s*\//.test(src)) {// For "about" page, the first part of "src" can't be removed.// In addition, to support multi-level local directory.var linkArray = link.split('/').filter(function(elem){return elem != '';});var srcArray = src.split('/').filter(function(elem){return elem != '' && elem != '.';});if(srcArray.length > 1)srcArray.shift();src = srcArray.join('/');$(this).attr('src', config.root + link + src);console.info&&console.info("update link as:-->"+config.root + link + src);}}else{console.info&&console.info("no src attr, skipped...");console.info&&console.info($(this));}});data[key] = $.html();}}});
在终端输入hexo new "文章英文名"
比如 hexo new "first-blog"
,将会在source/_posts下生成一个 文章名.md
文件 比如 first-blog.md
,同时生成一个同名文件夹 first-blog
,写文章的时候可以将图片放到该文件夹中。
手动进入目录 source/_posts
,打开刚刚新建的md文件,这里可以选择使用不同的编辑器,或者在一些网站上(比如CSDN)写好了再复制进来。
打开文件,你可以看到 例
--- title: first-blogdate: 2019-08-29categories: - - tags: - - ---
现在需要修改内容了
```---title: 我的第一篇博文 #文章标题date:2019-08-29 categories: #如果开启了多级分类,则可以按下面这样写,分类显示二级分类,文章在博客下的心得分类中 - 博客 #-前面tab,后面一个空格 - 心得tags: #可以这样写,会显示blog,博客,心得三个标签 - blog - 博客 - 心得---下面写文章内容,markdown语言,自己搜一下.比如 ## 二级标题 #注意空格> 引用或强调```C++std::cout << "hello" << endl;```
hexo d
hexo s
,打开网页测试,没错误就可以输入下面的命令了hexo d -g
文章汇总:
Mac使用Hexo和GitHub搭建博客(1) |
Mac使用Hexo和GitHub搭建博客(2) |
Mac使用Hexo和GitHub搭建博客(3) |
Mac使用Hexo和GitHub搭建博客(4) |
搭建博客的时候顺便改了下基本的配置,现在来看下这些配置修改
~/blog/_config.yml
这个是全局的配置文件,上一个博客已经讲的很清楚了,这里不再赘述
由于需要用主题3-hexo高亮代码,将这里的高亮渲染关闭
highlight: enable: false
~/blog/themes/3-hexo/_config.yml
这个是主题的配置文件,仅给出需要修改的地方
你的头像url 需要到~/blog/themes/3-hexo/source/img下把avatar.jpg替换为自己头像
avatar: /img/avatar.jpgfavicon: /img/avatar.jpg
博客位置,如果没有错误不需要修改
blog_path: /
链接图标 将链接全部改为自己的即可
csdn: https://me.csdn.net/qq_36949103
多作者模式 按需求填写author: on: false authors: author1: luwang author2: wallleap
分类文章数、多级分类 按需启用
category: num: true # 分类显示文章数 sub: true # 开启多级分类
文末声明 改为自己的
`
article_txt:
> 打赏功能 需要到~/blog/themes/3-hexo/source/img下把weixin.jpg和alipay.jpg替换为自己微信和支付宝收款码
reward: true
> 其他的都有说明,自己看着修改就行> 评论系统启用方式:[完美替代多说-gitment](https://yelog.org/2017/06/26/gitment/)## 二、优化页面### 1、主页 `~/blog/themes/3-hexo/indexs.md`由于是.md文件,因此可以按照正常的Markdown语法进行修改### 2、发布页模板 `~/blog/scaffolds/post.md`为了以后写博文方便,可以按照习惯修改模板,我的模板如下:
title: Mac使用Hexo和GitHub搭建博客(2)--优化配置
date: 1566649319000
tags:
- tag1- tag2
categories:
- category1- category2
`
标签改为多标签,分类为二级分类
hexo new page "about"
还有category等都可以添加
about页还需要修改主题_config.yml:
进入到购买域名的控制台,找到域名服务或解析服务
点击自己域名后的解析设置
点击添加记录
按照下图填写,注意记录值填自己的用户名.github.io
也可以再添加主机记录用www的,这样输入www也能访问
做完了解析工作还是不行的,需要在仓库加上CNAME文件,文件中只需要填写域名,比如我的:
由于仓库中上传时会自动删除,因此放到~/blog/source/
下
上面主题配置中有提到过,但对于一个博客而言,评论部分是不可或缺的,因此将其单独说明。
由于本人只用过gitment
和gitalk
,而个人感觉gitalk
更好用一点,因此这里介绍gitalk
使用,上面有gitment
的教程链接
首先打开主题配置文件(~/blog/themes/3-hexo/_config.yml
),找到评论设置,将comment字段的on设为true,type设为gitalk。找到gitalk字段,添加on:true,其他的评论系统字段添加on:false.接着打开链接https://github.com/settings/applications/new,登录GitHub账户,
注意callbalk URL一定要是自己域名的地址,接着点击绿色按钮,把Client ID和Client Secret复制到主题配置文件的gitalk字段相应位置,接着githubID和adminUser填自己的用户名即可,repo填博客的仓库(即用户名.github.io
)
文章汇总:
Mac使用Hexo和GitHub搭建博客(1) |
Mac使用Hexo和GitHub搭建博客(2) |
Mac使用Hexo和GitHub搭建博客(3) |
Mac使用Hexo和GitHub搭建博客(4) |