方舟笔记

方舟笔记

Linux 详细配置 Net-SNMPv3 与获取SNMP数据

简单网络管理协议(SNMP) 是专门设计用于在 IP 网络管理网络节点(服务器、工作站、路由器、交换机及HUBS等)的一种标准协议,它是一种应用层协议。
SNMP(简单网络管理协议)是基于UDP端口161,为管理站使用UDP端口162。

Linux 详细配置 Net-SNMPv3 与获取SNMP数据
CentOS Fedora
yum -y install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils
或者
yum install -y net-snmp*

配置文件 /etc/snmp/snmpd.conf ,清空( vi编辑器键入dGi )所有内容后填入以下内容

Net-SNMPv2的配置信息
#192.99.12.76为数据收集服务器ip,yonghumima为snmp密码(community)
com2sec yonghuming 192.99.12.76 yonghumima
group yonghuzu v2c yonghuming
access yonghuzu "" any noauth prefix all none none
view all included .1 80

启动服务
chkconfig --add snmpd;chkconfig snmpd on;
-------
Ubuntu Debian
apt-get install snmp snmpd
配置文件 /etc/snmp/snmpd.conf

配置 Net-SNMPv3,创建用户密码
service snmpd stop #先停止snmp的运行

我们这里创建一个一个snmpv3用户,位只读,使用MD5加密传输,用户名为yonghuming,密码为yonghumima。
#net-snmp-config --create-snmpv3-user -ro -A yonghumima -a MD5 yonghuming
(The supplied password length is too short.)
adding the following line to /var/lib/net-snmp/snmpd.conf:
createUser yonghuming MD5 "yonghumima" DES
adding the following line to /etc/snmp/snmpd.conf:
rouser yonghuming

service snmpd restart
cat /var/lib/net-snmp/snmpd.conf #账户密码存放文件
...
usmUser 1 3 0x80001f8880549a357563fd815700000000 "yonghuming" "yonghuming" NULL .1.3.6.1.6.3.10.1.1.2 0x6454631b1ce32f299000d5170b431cba .1.3.6.1.6.3.10.1.2.2 0x6454631b1ce32f299000d5170b431cba ""
...

检测 Net-SNMPv3账户密码
#snmpwalk -v 3 -u yonghuming -a MD5 -A "yonghumima" -l authNoPriv 127.0.0.1 sysDescr

设计防火墙,允许数据通过
iptables -I INPUT -p udp --dport 161 -j ACCEPT
service iptables save;service iptables restart

删除或者修改默认密码
sed -i 's@^com2sec notConfigUser default public@com2sec notConfigUser default@' /etc/snmp/snmpd.conf #删除密码

重启服务
service snmpd restart

获取snmp数据
#snmpwalk -v 3 -u yonghuming -a MD5 -A "yonghumima" -l authNoPriv 122.9.44.224 sysDescr
SNMPv2-MIB::sysDescr.0 = STRING: Linux 3.10.0-327.22.2.el7.x86_64 #1 SMP Thu Jun 23 17:05:11 UTC 2016 x86_64

#snmpwalk -v 3 -u yonghuming -a MD5 -A "yonghumima" -l authNoPriv 122.9.44.224 .1 #获取所有数据

当cacti设备状态一直是不可用的时候,可以Create Graphs for this Host

修改Nginx源码,使header头信息伪装成其他页面服务器软件

nginx_header
Nginx 修改源码,header 头信息伪装成其他服务器软件

wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

1、修改编译nginx核心文件

vim ./src/core/nginx.h

/*
* Copyright (C) Igor Sysoev
* Copyright (C) Nginx, Inc.
*/

#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_

#define nginx_version 1006002 #这里最好不要乱改,某些扩展模块编译时,会检测版本,可能会出现错误,如lua_nginx_module
#define NGINX_VERSION "1.6.2" #这里随便改个版本号
#define NGINX_VER "squid/" NGINX_VERSION #这里改成我们想要的名字

#define NGINX_VAR "squid" #这里也一并修改
#define NGX_OLDPID_EXT ".oldbin"

Ruijie 10G Ethernet Switch with PoE (S2910C-48GT2XS-HP-E)

switch0

switch1
C315#show version
System description : Ruijie 10G Ethernet Switch with PoE (S2910C-48GT2XS-HP-E) By Ruijie Networks
System start time : 2016-06-17 11:06:19
System uptime : 0:00:18:58
System hardware version : 1.01
System software version : S2910_RGOS 11.4(1)B1
System patch number : NA
System serial number : G1J90L5000711
System boot version : 1.2.12
Module information:
Slot 0 : S2910C-48GT2XS-HP-E
Cpu 0:
Hardware version : 1.01
System start time : 2016-06-17 11:06:19
Boot version : 1.2.12
Software version : S2910_RGOS 11.4(1)B1
Serial number : G1J90L5000711

ESXi 5.5 配置firewall rule只允许特定的IP地址或者网段访问SSH和SNMP服务

ESXi 5.5 配置firewall rule只允许特定的IP地址或者网段访问SSH和SNMP服务
只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据
You can change the firewall rule to only allow a specific subnet or host if you would like to.

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

只允许特定的IP地址或者IP段能够访问SSH服务

esxcli network firewall ruleset list

esxcli network firewall ruleset set --ruleset-id sshServer --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 192.168.66.0/24
esxcli network firewall ruleset allowedip add --ruleset-id sshServer --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id sshServer --enabled true
/etc/init.d/SSH restart

防火墙保存位置/etc/vmware/firewall/

chmod 744 /etc/vmware/firewall/service.xml
chmod +t /etc/vmware/firewall/service.xml

Refresh the firewall rules for the changes to take effect by running the command:
esxcli network firewall refresh
or
localcli network firewall refresh

reboot -f 重启ESXi,非必要步骤。
firewall_rule

开启VMware ESXi 5.5的SNMP服务

因为需要监控ESXi vSphere 5.5 hosts 的数据,准备使用SNMP的方式获取需要的数据。但是发现ESXi5.5的SNMP默认是没有开启的(false),因此需要设置密码和开启ESXi的SNMP服务,为了安全起见只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据。

默认ESXi snmp的服务是关闭状态的

~ # cat /etc/vmware/snmp.xml
snmp_xml

esxcli system snmp set --communities public #设置SNMP的密码,建议不要使用通用的snmp密码public
esxcli system snmp set --enable true #设置启用snmp

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true #设置运行ESXi的防火墙通过snmp
esxcli network firewall ruleset set --ruleset-id snmp --enabled true

/etc/init.d/snmpd restart #重新启动snmp

You can change the firewall rule to only allow a specific subnet or host if you would like to.
为了安全起见只允许特定的IP地址或者IP段能够获取ESXi的SNMP的数据

esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false
esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address 192.168.12.0/24
esxcli network firewall ruleset set --ruleset-id snmp --enabled true
/etc/init.d/snmpd restart

# snmpwalk -v 2c -c public 192.168.12.237 .1 | grep Huawei
SNMPv2-SMI::mib-2.47.1.1.1.1.2.1 = STRING: "Huawei Technologies Co., Ltd. RH1288 V3"
SNMPv2-SMI::mib-2.47.1.1.1.1.12.1 = STRING: "Huawei Technologies Co., Ltd."

snmpwalk -v 2c -c public 192.168.12.237 sysDescr.0

snmpwalk -v 2c -c public 192.168.12.237 hrDeviceDescr.1

snmpwalk -v 2c -c public 192.168.12.237 mib-2.47.1.1.1.1.2.1

snmpwalk -v 2c -c public 192.168.12.237 enterprises.6876.3.5.2.1.5.1

使用 SNMPv2-MIB监控VMWARE ESXi的设备
esxi_open_snmp_service

esxi_snmp_mib

使用 GNS3.VM.VMware.ESXI 或 GNS3.VM.VMware.Workstation

使用 GNS3.VM.VMware.ESXI 或 GNS3.VM.VMware.Workstation
GNS3, the Graphical Network Simulator. Run Cisco, Juniper and open-source virtual networks on your PC

1、安装VMware Workstation或者ESXi
2、将GNS3 VM “导入虚拟机中 https://github.com/GNS3/gns3-gui/releases
3、启动GNS3 VM
4、配置IP地址,使用ifconfig命令,获取eth0口IP地址。#老版本需要使用用户名root和密码cisco登录
新版本的选中Networking,修改iface eth0 inet status,默认编辑器Nano(如果你要保存所做的修改,按下Ctrl+O。想要退出,按下Ctrl+X。如果你退出前没有保存所做的修改,它会提示你是否要保存。如果不要,请按N,反之,则按Y。然后它会让你确认要保存的文件名,确认或修改后按Enter即可。如果你没有修改好而不小心按了保存键,您可以在请求确认文件名时按Ctrl+C来取消。)
5、打开Web浏览器并转到 http://10.140.3.3:8000/upload ,上传IOU image文件。
记住文件路径,//opt/gns3/images/IOU/i86bi-linux-l2-adventerprise-15.1b.bin

6、在GNS3安装目录,创建一个名为iourc.txt的许可证编号文本文件,内容如(注意是上下两行):

[license]
gns3-iouvm = cd11acbc599f2364;

7 、启动GNS3,进入Preferences -> Server -> Remote servers,并添加虚拟机的IP地址,10.140.3.3 ,单击Apply(应用)。

8、Preferences-> Dynamips-> IOS routers-> new,-> 1:Run the IOS on a remote computer 计算 Idle-pc values
-> 2:Run tne IOS on your local computer
9、IOSon UNIX
Path to IOURC(license)
IOU Device templates new Run the IOU on a remote computers

gns3146

Windows 配置静态路由和配置永久静态路由

Windows 配置静态路由和配置永久静态路由

在使用多网卡多网段的情况下只能给其中一个配置default gate way(如果配置多个default gate way,会造成无法上网),其他的网段就需要配置静态路由。

浪潮SA5112M4一共四个网卡接口,接口配置信息如下

网卡1:
116.255.166.188
255.255.255.0
116.255.166.1

网卡2:
10.140.88.140
255.255.0.0
10.140.0.1

Windows 配置静态路由
route add 10.0.0.0 mask 255.0.0.0 10.140.0.1

Windows 配置永久静态路由
route -p add 10.0.0.0 mask 255.0.0.0 10.140.0.1

-f 清除所有网关项的路由表。如果与某个
命令结合使用,在运行该命令前,
应清除路由表。

-p 与 ADD 命令结合使用时,将路由设置为
在系统引导期间保持不变。默认情况下,重新启动系统时,
不保存路由。忽略所有其他命令,
这始终会影响相应的永久路由。
win_default_route (1)

win_default_route (2)

IPV6链路地址分类

Aggregate global unicast address
可聚集全球单播地址 001x xxxx xxxx xxxx::
2400 0010 0100 0000 0000
2400:6180:0:d0::47f:1001/64
2400:6180:0:d0:0000:0000:47f:1001/64
#ping6 2400:6180:0:d0:0000:0000:47f:1001
PING 2400:6180:0:d0:0000:0000:47f:1001(2400:6180:0:d0::47f:1001) 56 data bytes
64 bytes from 2400:6180:0:d0::47f:1001: icmp_seq=1 ttl=64 time=3.23 ms

Unspecified address
IPv6中的未指定地址即0:0:0:0:0:0:0:0/128 或者::/128

Loopack address
IPv6中的环回地址即0:0:0:0:0:0:0:1/128 或者::1/128 相当于IPv4中的127.0.0.1/8,主要用于设备给自己发送报文。
#ping6 ::1
PING ::1(::1) 56 data bytes
64 bytes from ::1: icmp_seq=1 ttl=64 time=0.041 ms
64 bytes from ::1: icmp_seq=2 ttl=64 time=0.046 ms

Link Local Address 链路本地地址 FE80::/10(最高10位值为1111111010)(1111 1110 1000 0000)唯一本地单播地址
链路本地地址是IPv6中的应用范围受限制的地址类型,只能在连接到同一本地链路的节点之间使用。似于ipv4中,当DHCP分配失败时自动生成的类似于169.254.0.0/16这样的地址,凡是源地址或目的地址中含有link-local address的报文,路由器都不应当转发它,这样的报文只能在一个LAN中互通。

(ULA,unique local address)唯一区域地址FC00::/7(最高7位值为1111110) (1111 1100 0000 0000)
唯一本地地址是另一种应用范围受限的地址,它仅能在一个站点内使用。由于本地站点地址的废除(RFC3879),唯一本地地址被用来代替本地站点地址(RFC4193)
唯一本地地址的作用类似于IPv4中的私网地址,任何没有申请到提供商分配的全球单播地址的组织机构都可以使用唯一本地地址。

IPv6的组播与IPv4相同,用来标识一组接口,一般这些接口属于不同的节点。IPv6组播地址的前缀是FF00::/8
IPv6中没有为任播规定单独的地址空间,任播地址和单播地址使用相同的地址空间。

Server1:inet6 addr: fe80::250:56ff:fe90:32d8/64 Scope:Link
Server2:inet6 addr: fe80::250:56ff:fe90:4625/64 Scope:Link

#ping6 fe80::250:56ff:fe90:4625
connect: Invalid argument

ping6 -I eth0 fe80::250:56ff:fe90:4625
PING fe80::250:56ff:fe90:4625(fe80::250:56ff:fe90:4625) from fe80::250:56ff:fe90:32d8 eth0: 56 data bytes
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=1 ttl=64 time=2.02 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=2 ttl=64 time=0.169 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=3 ttl=64 time=0.147 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=4 ttl=64 time=0.224 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=5 ttl=64 time=0.187 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=6 ttl=64 time=0.172 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=7 ttl=64 time=0.157 ms
64 bytes from fe80::250:56ff:fe90:4625: icmp_seq=8 ttl=64 time=0.153 ms

ping6 -I enp0s3 fe80::1
PING fe80::1(fe80::1) from fe80::1 enp0s3: 56 data bytes
64 bytes from fe80::1: icmp_seq=1 ttl=64 time=0.017 ms
64 bytes from fe80::1: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from fe80::1: icmp_seq=3 ttl=64 time=0.032 ms

Google to the rescue, you have to specify the network interface you want to use to send the packet. It’s ok ping6 has a -I parameter that allows you to select the one you want, and you also find that there is a weird syntax that allows you to do that inline
fe80 (1)

fe80 (2)