wenmo8 发布的文章

Part1需求说明

图片

  • 配置PC1和PC2的IP地址

  • 设置防火墙GE1/0/0和GE1/0/1的IP地址

  • 将接口加入防火墙安全区域

  • 配置域间包过滤策略

  • 配置NAT地址池,公网地址范围2.2.2.2-2.2.2.5

  • 配置NAT policy

  • 验证结果,从PC1 ping PC2地址,使用display firewall session table命令查看NAT转换情况。

Part2配置过程

1配置PC1和PC2的IP地址

根据拓扑图,PC1配置如下IP地址、掩码、网关,配置完后记得点击应用:

图片根据拓扑图,PC2配置如下IP地址、掩码、网关,配置完后记得点击应用:

图片

2设置防火墙GE1/0/0和GE1/0/1的IP地址

首次登陆,防火墙默认账号为admin,密码为Admin@123

图片

进行设置防火墙的接口IP地址:

[USG6000V1]int g1/0/0

[USG6000V1-GigabitEthernet1/0/0]ip add 192.168.1.1 24

[USG6000V1-GigabitEthernet1/0/0]ip binding vpn-instance default

[USG6000V1-GigabitEthernet1/0/0]qu

[USG6000V1]

[USG6000V1]int g0/0/0

[USG6000V1-GigabitEthernet0/0/0]ip add 2.2.2.1 24

[USG6000V1-GigabitEthernet0/0/0]qu

[USG6000V1]

3将接口加入防火墙安全区域

[USG6000V1]firewall zone trust  

[USG6000V1-zone-trust]add interface GigabitEthernet 1/0/0

[USG6000V1-zone-trust]add interface GigabitEthernet 0/0/0

[USG6000V1-zone-trust]

4配置域间包过滤策略

配置策略如下:

[USG6000V1]security-policy 

[USG6000V1-policy-security]rule name policy-permit01

[USG6000V1-policy-security-rule-policy-permit01]source-address 192.168.1.0 24

[USG6000V1-policy-security-rule-policy-permit01]destination-address 2.2.2.0 24

[USG6000V1-policy-security-rule-policy-permit01]action permit

[USG6000V1-policy-security-rule-policy-permit01]quit

[USG6000V1-policy-security]quit

[USG6000V1]

5配置NAT地址池,公网地址范围2.2.2.2-2.2.2.5

[USG6000V1]nat address-group add-group01

[USG6000V1-address-group-add-group01]section 0 2.2.2.2 2.2.2.5

[USG6000V1-address-group-add-group01]mode pat

[USG6000V1-address-group-add-group01]qu

[USG6000V1]

6配置NAT policy

[USG6000V1]nat-policy 

[USG6000V1-policy-nat]rule name nat-policy01

[USG6000V1-policy-nat-rule-nat-policy01]source-address 192.168.1.0 24

[USG6000V1-policy-nat-rule-nat-policy01]destination-address 2.2.2.0 24

[USG6000V1-policy-nat-rule-nat-policy01]action source-nat  address-group add-group01

[USG6000V1-policy-nat-rule-nat-policy01]quit

[USG6000V1-policy-nat]quit

[USG6000V1]

7验证结果

从PC1 ping PC2地址,使用display firewall session table命令查看NAT转换情况。

图片图片

上图,我们可以看到192.168.1.10这个源IP地址被替换成2.2.2.4这个IP了。

接下来,我们也可以在PC1和PC2接口上抓包,观察他们的源IP地址是否有变化:

图片图片图片图片图片

通过上图,小白们应该能对NAT源地址转换有个更清晰的认识了吧!


Part1组网需求

在一个新建的数据中心网络中,要求核心层具有较高的可靠性,并且希望网络结构简单,易于配置和管理。

如图1所示,根据用户需求,核心层SwitchA和SwitchB两台交换机采取堆叠组网。配置堆叠组网图图片

Part2配置思路

采用如下的思路配置:
1、提前规划好堆叠方案。

2、按照前期的规划,连接好SwitchA和SwitchB之间的堆叠线缆。

3、在SwitchA和SwitchB上进行堆叠软件配置,包括堆叠成员ID、堆叠优先级、堆叠域编号、堆叠端口等。

4、保存SwitchA和SwitchB的配置,并使能堆叠功能。

5、检查堆叠组建是否成功。

Part3操作步骤

1提前规划堆叠方案。

  • 规划SwitchA的堆叠成员ID为1,SwitchB的成员ID为2。
  • 规划SwitchA作为主交换机,其堆叠优先级最高,为150。SwitchB的堆叠优先级为100。
  • 规划堆叠域编号(Domain ID)为10,不与网络中其他堆叠系统的域编号冲突。
  • SwitchA和SwitchB各使用两块业务板进行堆叠转发链路的连接,用于连接的端口为10GE1/0/1~10GE1/0/2、10GE2/0/1~10GE2/0/2。

2连接堆叠线缆。

如图2所示,按照前期规划连接SwitchA和SwitchB之间的堆叠线缆。连接的端口包括主控板上的SIP口和业务板上的堆叠物理成员端口。图2 堆叠连接示意图

图片

3配置堆叠属性。

配置SwitchA的堆叠成员ID为1,优先级为150,Domain ID为10。

<HUAWEI> system-view
[~HUAWEI] sysname SwitchA
[*HUAWEI] commit
[~SwitchA] stack
[~SwitchA-stack] stack member 1
[~SwitchA-stack] stack priority 150
Info: The operation will take effect after reboot.
[*SwitchA-stack] stack domain 10
Info: The operation takes effect only after the save command is executed. The device with a lower priority then will be reset in the stack merging scenario. 
[*SwitchA-stack] quit
[*SwitchA] commit

配置SwitchB的堆叠成员ID为2,优先级为100,Domain ID为10。

<HUAWEI> system-view
[~HUAWEI] sysname SwitchB
[*HUAWEI] commit
[~SwitchB] stack
[~SwitchB-stack] stack member 2
Warning: The device will use the configuration of member ID 2 after the device resets. Continue? [Y/N]: y
[*SwitchB-stack] stack priority 100
[*SwitchB-stack] stack domain 10
Info: The operation takes effect only after the save command is executed. The device with a lower priority then will be reset in the stack merging scenario. 
[*SwitchB-stack] quit
[*SwitchB] commit

4配置堆叠端口。

在SwitchA上创建堆叠端口,并将端口10GE1/0/1~10GE1/0/2、10GE2/0/1~10GE2/0/2加入堆叠端口。在SwitchB上创建堆叠端口,并将端口10GE1/0/1~10GE1/0/2、10GE2/0/1~10GE2/0/2加入堆叠端口。SwitchB的配置与SwitchA类似,配置过程略。

[~SwitchA] port-group group1
[*SwitchA-port-group-group1] group-member 10ge 1/0/1 to 10ge 1/0/2
[*SwitchA-port-group-group1] group-member 10ge 2/0/1 to 10ge 2/0/2
[*SwitchA-port-group-group1] shutdown
[*SwitchA-port-group-group1] quit
[*SwitchA] commit
[~SwitchA] interface stack-port 1
[*SwitchA-Stack-Port1] port member-group interface 10ge 1/0/1 to 1/0/2
Warning: After the configuration is complete,
1.The interface(s) (10GE1/0/1-1/0/2) will be converted to stack mode and be configured with the port crc-statistics trigger error-down command if the configuration does not exist.
2.The interface(s) may go Error-Down (crc-statistics) because there is no shutdown configuration on the interfaces.Continue? [Y/N]: y
[*SwitchA-Stack-Port1] port member-group interface 10ge 2/0/1 to 2/0/2
Warning: After the configuration is complete,
1.The interface(s) (10GE2/0/1-2/0/2) will be converted to stack mode and be configured with the port crc-statistics trigger error-down command if the configuration does not exist.
2.The interface(s) may go Error-Down (crc-statistics) because there is no shutdown configuration on the interfaces.Continue? [Y/N]: y
[*SwitchA-Stack-Port1] quit
[*SwitchA] commit

被配置为堆叠物理成员端口后,端口下会自动配置port crc-statistics trigger error-down

待SwitchA和SwitchB上的物理端口都加入堆叠端口后,再将之前被关闭的端口打开。SwitchB的配置与SwitchA类似,配置过程略。

[~SwitchA] port-group group1
[~SwitchA-port-group-group1] undo shutdown
[*SwitchA-port-group-group1] quit
[*SwitchA] commit
[~SwitchA] quit

端口先关闭然后再打开,这样是为了避免端口因产生CRC错包而导致Error-Down。在端口Up的情况下,如果链路一端被配置为堆叠物理成员端口,另一端为普通业务口,此时端口可能会产生CRC错包。

5检查堆叠配置信息。

上述配置完成后,执行命令display stack configuration查看配置是否与规划的一致,如果不一致,需要修改配置。以查看SwitchA为例。

<SwitchA> display stack configuration
Oper          : Operation
Conf          : Configuration
MB            : MainBoard
*             : Offline configuration
Isolated Port : The port is in stack mode, but does not belong to any Stack-Port

Attribute Configuration:
---------------------------------------------------------------
 MemberID      Domain         Priority       Mode     Enable
Oper(Conf)   Oper(Conf)      Oper(Conf)   Oper(Conf)   Oper
---------------------------------------------------------------
1(1)         --(10)          100(150)     MB(MB)       Disable
---------------------------------------------------------------

Stack-Port Configuration:
--------------------------------------------------------------------------------
Stack-Port      Member Ports
--------------------------------------------------------------------------------
Stack-Port1     10GE1/0/1           10GE1/0/2           10GE2/0/1
                10GE2/0/2
--------------------------------------------------------------------------------

6保存配置并使能设备堆叠功能。

保存SwitchA的配置并使能堆叠功能。建议先使能规划为主交换机的SwitchA的堆叠功能。这样SwitchA可以先完成重启,从而优先成为主交换机。

<SwitchA> save
Warning: The current configuration will be written to the device. Continue? [Y/N]: y
<SwitchA> system-view
[~SwitchA] stack
[~SwitchA-stack] stack enable
Warning: Make sure that one or more dual-active detection methods are configured once the conversion is complete and the device enters the stack mode. Switches working in different forward modes cannot set up a CSS.
Current configuration will be converted to the next startup saved-configuration file of stack mode.
System will reboot. Continue? [Y/N]: y

使能堆叠功能后,设备会自动重启。

保存SwitchB的配置并使能堆叠功能。

<SwitchB> save
Warning: The current configuration will be written to the device. Continue? [Y/N]: y
<SwitchB> system-view
[~SwitchB] stack
[~SwitchB-stack] stack enable
Warning: Make sure that one or more dual-active detection methods are configured once the conversion is complete and the device enters the stack mode. Switches working in different forward modes cannot set up a CSS.
Current configuration will be converted to the next startup saved-configuration file of stack mode.
System will reboot. Continue? [Y/N]: y

7检查堆叠是否组建成功。

通过Console口或管理网口登录堆叠系统,使用命令display stack查看堆叠是否组建成功。当通过管理网口登录时,需要使用主交换机的IP地址。

<SwitchA> display stack
--------------------------------------------------------------------------------
MemberID Role     MAC              Priority   DeviceType         Description
--------------------------------------------------------------------------------
1        Master   006d-8835-2b00   150        CE16804
2        Standby  006d-8835-2c00   100        CE16804
--------------------------------------------------------------------------------

如上所示,显示两台交换机的信息,表示堆叠建立成功,且主交换机为成员ID为1的设备,即SwitchA。

8保存堆叠系统配置。

在检查堆叠已成功建立后,建议用户立即使用save命令保存堆叠系统配置。

<SwitchA> save
Warning: The current configuration will be written to the device. Continue? [Y/N]: y



Eclipse下创建WebService项目,主要目的是作为Postman、soapUI等工具进行soap webservice 接口测试的案例。

本文基于Axis2框架,在eclipse环境下搭建webservice项目,以用于后期使用SoapUI进行webservice接口测试。

1、下载Axis2框架

在官网axis.apache.org/axis2/j下载web service框架Axis2,这是Apache的一个子项目,注意下载的版本,最好和jdk版本匹配,JDK1.8需要下载1.7.x版本的。

2、在eclipse中集成Axis2框架

打开eclipse软件,选择一个工程目录:webservice,然后window->preferences->Web Services->Axis2 Preferences,在其中加载解压后的axis文件夹。

3、创建web项目,并提供对外访问的java类和方法

File->New->Project->web,选择Dynamic Web Project,点击下一步:

其中NewRuntime,需要配置Tomcat,如果已经安装过,只需要在此处设置安装目录即可,如果jre是1.8_xxx,选择tomcat7版本。

完成上面配置,直接点击Finish按钮,完成项目创建。生成的工程目录如下:

再在Java Resources->src下创建包:com.qf,在包下创建一个类:FirstDemo.java

其中实现如下类和方法的创建:

package com.qf;

import java.util.ArrayList;

public FirstDemo  {
	//创建第一个对外开放的接口方法
        //获取姓名接口
	public String getName(String name){
		if(name == null || name.equals("null") || name.equals("")){
			name = "there is no this name!!";
			return name;
		}
		System.out.println("姓名是:"+name);
		return "welcome "+name+" , to QIANFENG testing.";
	}

	//获取姓名列表接口
	public String getNameList(){
		ArrayList al = new ArrayList();
		al.add("allen");
		al.add("petter");
		al.add("Lucy");
		System.out.println(al.toString());
		return al.toString();
	}
	//获取加法运算结果接口
	public int sum(int a, int b){
		return a+b;
	}
	
}

4、选择项目的web service

鼠标右键New->Other->Web Service->Web Service选中,点击next。

按照下面页面进行设置,其中需要点击Browser选择刚创建的java文件,点击下一步。

选择对外开放的接口方法,点击下一步:

点击页面的Start server,启动Tomcat服务(注意端口问题,默认是8080端口,若有占用此端口的需要关闭其再试)

启动Tomcat服务成功后,改按钮会置灰,Eclipse控制台会显示tomcat启动日志,并处于服务状态,点击该页面的Finish完成配置。

在弹出的页面中如图设置,验证通过,则web service服务搭建成功。

5、查看wsdl文件

通过xml文件打开,可以找到该服务提供的接口地址,末尾拼接wsdl :localhost:8080/WebSerDe

复制该地址到浏览器中,可以查看xml格式的内容:

在浏览器中输入:http://localhost:8080/WebSerDemo/services,点击图示按钮,也可以打开上文的wsdl文件。

记住这个地址:http://localhost:8080/WebSerDemo/services/FirstDemo?wsdl

如果我们自建个人网站并不需要特别复杂的功能的时候,并不一定非要选择WordPress。并且WordPress真要完好确实需要一定的技术能力,尤其是后续的功能和优化需要琢磨才能使用的更好。一般普通个人网站完全可以使用Typecho,算是比较好的轻量博客程序,当然我们也看到很多个人使用Typecho做的网站也都很好。

大部分网友唯独不是特别满意Typecho的就是编辑器采用的是Markdown编辑器。毕竟官方考虑到是整个程序的体积和轻便,不过对于很多人来说不是特别喜欢这个编辑器。我们可以安装其他编辑器来丰富编辑功能,其中可以安装的是UEditor for Typecho。UEditor由百度提供的,然后有其他网友进行整合兼容到Typecho,我们一起安装看看吧。

第一、UEditor for Typecho下载和安装

下载地址:https://github.com/chanshengzhi/UEditor-for-Typecho


我们下载之后解压,然后将UEditor文件夹丢到当前Typecho主题下的usr/plugins文件夹下。

第二、UEditor for Typecho激活使用

1、暂停当前编辑器

我们需要在控制台-个人设置中关闭当前的编辑器。

2、激活编辑器

控制台-插件,找到当前安装的UEditor for Typecho插件进行激活。这个时候我们再去编辑文章看看是什么编辑器?

是不是比较丰富?

第三、UEditor for Typecho附加功能

如果我们需要将编辑器出现的静态文件,比如图片附件不在本地保存。可以配置到腾讯云COS或者又拍云。

总结,如果我们需要在Typecho较为丰富的编辑器是可以安装UEditor for Typecho插件的。


进程对应的内存空间中所包含的5种不同的数据区:

BSS段:BSS段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域。BSS是英文Block Started by Symbol的简称。BSS段属于静态内存分配。

数据段:数据段(data segment)通常是指用来存放程序中已初始化的全局变量的一块内存区域。数据段属于静态内存分配。

代码段:代码段(code segment/text segment)通常是指用来存放程序执行代码的一块内存区域。这部分区域的大小在程序运行前就已经确定,并且内存区域通常属于只读, 某些架构也允许代码段为可写,即允许修改程序。在代码段中,也有可能包含一些只读的常数变量,例如字符串常量等。

堆(heap):堆是用于存放进程运行中被动态分配的内存段,它的大小并不固定,可动态扩张或缩减。当进程调用malloc等函数分配内存时,新分配的内存就被动态添加到堆上(堆被扩张);当利用free等函数释放内存时,被释放的内存从堆中被剔除(堆被缩减)

栈(stack):栈又称堆栈, 是用户存放程序临时创建的局部变量,也就是说我们函数括弧“{}”中定义的变量(但不包括static声明的变量,static意味着在数据段中存放变量)。除此以外,在函数被调用时,其参数也会被压入发起调用的进程栈中,并且待到调用结束后,函数的返回值也会被存放回栈中。由于栈的先进后出特点,所以栈特别方便用来保存/恢复调用现场。从这个意义上讲,我们可以把堆栈看成一个寄存、交换临时数据的内存区。

以前老是为了防止变量重名,喜欢在函数里设置局部变量,感觉没啥区别,但是刷题时在main函数中定义大容量的数组时,程序有时就会报错,改成全局变量时就好了。

数组定义在函数中会占用 栈空间 ,而往往栈空间比较小,所以大数组定义在函数中会出现内存方面的问题。
但是如果将数组定义为全局变量 则分配在 数据段,则不存在所谓的内存问题!

所以遇到大容量数组,尽量还是定义为全局变量更好