方舟笔记

方舟笔记

CentOS第三方软件源RepoForge已经死亡

RepoForge might be outdated. We have no updates since very long time.
pkgs.repoforge.org is DOWN

The Centos wiki has flagged repoforge as a dead project.
CentOS第三方软件源RepoForge Repo已经死亡
RPMForge/RepoForge is a dead project. It is not maintained. DO NOT USE.
https://wiki.centos.org/zh/AdditionalResources/Repositories/RPMForge

The repo & all the mirrors are presently inaccessible. The Centos wiki has flagged repoforge as a dead project. Any plans of reversing this? Too much important software here to lose it.

CentOS 6.x使用dropbox并定时同步数据

CentOS 6.x使用dropbox并定时同步数据
Dropbox成立于2007年,提供免费和收费服务,在不同操作系统下有客户端软件,并且有网页客户端,能够将存储在本地的文件自动同步到云端服务器保存。

  • 1、安装Dropbox
  • 2、获取帮助
  • 3、解绑Dropbox
  • 4、开机启动
  • 5、备份数据
  • https://www.dropbox.com/install?os=lnx
    1、安装Dropbox
    32-bit
    wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
    64-bit
    wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -
    从新建的 .dropbox-dist 文件夹运行 Dropbox 守护程序。
    ~/.dropbox-dist/dropboxd
    会出现一个链接,需要登录网页确认来关联此设备
    请访问 https://www.dropbox.com/cli_link_nonce?nonce=00873e432b668e9c6637642850a7edce 来关联此设备。

    使用官方Python 脚本通过命令行控制 Dropbox
    mkdir -p ~/bin
    wget -O ~/bin/dropbox.py "https://www.dropbox.com/download?dl=packages/dropbox.py"
    chmod +x ~/bin/dropbox.py

    2、获取帮助
    ~/bin/dropbox.py help

    which will show you all the commands you can use

    status 获取 dropboxd 的运行状态
    help 提供帮助
    puburl 获取一个文件的共享链接
    stop 停止 dropboxd
    running 返回 dropboxd 是否在运行
    start 运行 dropboxd
    filestatus 获取一个或多个文件的同步状态
    ls 显示文件(夹)的同步状态
    autostart 用户登录时自动启动 dropboxd
    exclude 同步时排除文件夹
    lansync 启用禁用局域网同步

    ~/bin/dropbox.py status
    ~/bin/dropbox.py statrt
    ~/bin/dropbox.py exclude list
    ~/bin/dropbox.py exclude add ~/Dropbox/blogkms

    3、解绑Dropbox
    如果你的主机换了,原来的Dropbox确定不用,解绑你的账户和bropbox的关联
    在官网登录你的账户
    在右上角点击你的名字
    在下拉菜单中找到设置(setting)
    选择安全(security)选项卡
    在网页下面找到设备(devices)
    点击对应设备后面的X解绑

    删除linux主机上的一切有关文件(注意备份)
    rm -rf ~/.dropbox Dropbox .dropbox-dist

    4、开机启动
    vi /etc/rc.local
    su - xxx -c "~/bin/dropbox.py start" #su - root -c "~/bin/dropbox.py start"
    # xxx为你的用户名

    每天的00:05和12:05运行,然后在15min后停止运行。
    # dropbox
    5 00,12 * * * sh ~/dropbox.sh start
    20 00,12 * * * sh ~/dropbox.sh stop

    5、备份数据
    vi backup.sh

    #!/bin/sh
    #需要事先创建好/root/Dropbox/blogkms备份文件夹
    bpDIR="/root/Dropbox/blogkms"
    scDIR="/data/wwwroot"
    cfDIR="/usr/local/nginx/conf"
    rm -rf "$bpDIR/web.$(date -d -10day +%Y.%m.%d.)*.tar.gz"
    rm -rf "$bpDIR/conf.$(date -d -10day +%Y.%m.%d.)*.tar.gz"
    rm -rf "$bpDIR/sql.$(date -d -10day +%Y.%m.%d.)*.sql"
    #删除10天前备份的数据

    tar zcvf "$bpDIR/conf.$(date +%Y.%m.%d.%H.%M.%S).tar.gz" "$cfDIR"
    #备份nginx配置文件

    tar zcvf "$bpDIR/web.$(date +%Y.%m.%d.%H.%M.%S).tar.gz" --exclude=SuHu "$scDIR"
    #备份网站文件

    /usr/local/mysql/bin/mysqldump -ublog -pGUIOygC7xivA --databases blog > "$bpDIR/sql.$(date +%Y.%m.%d.%H.%M.%S).sql"
    #备份数据库文件

    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