Blog

  • 思科路由器交换机使用ssh方式连接

    进入配置模式

    configure terminal

    一、设置enable密码

    enable secret password

    enable secret 5 $1$7W0A$UTAhixRjHMbE0kHPWZNMJ0

    二、给交换机命名

    hostname switch

    三、配置域名

    ip domain-name test.com

    四、启用AAA,并产生rsa密钥对

    aaa new-model
    crypto key generate rsa

    R1(config)#crypto key generate rsa
    The name for the keys will be: R1.router.jpuyy.com
    Choose the size of the key modulus in the range of 360 to 2048 for your
    General Purpose Keys. Choosing a key modulus greater than 512 may take
    a few minutes.

    How many bits in the modulus [512]: 1024
    % Generating 1024 bit RSA keys, keys will be non-exportable…[OK]

    注:rsa默认为512bits,建议采用768bits以上的长度,这样可开启对sshv2的支持

    五、配置用户名和口令

    username cisco password cisco

    六、配置登录方式为SSH。注意要将0-15全部配置为SSH方式,不然telnet仍可访问。

    line vty 0 4
     transport input ssh
    line vty 5 15
    transport input ssh

    最后可通过以下命令查看显示SSH配置信息

    R1#show ip ssh

    SSH Enabled – version 1.99
    Authentication timeout: 120 secs; Authentication retries: 3

  • 使用moto xt610作为modem的方法

    我这里使用的是上海电信的evdo rev.A网,3G。经过操过可以将电脑与手机通过usb连接,并使用3G流量上网。

    方法一:

    在ubuntu和windows下均可,在手机上

    设置->应用程序->开发,勾选USB调试;

    设置->无线和网络->绑定与便携式热点->勾选usb绑定;

    这里电脑已经多出来一个网卡可以上网了,分配的ip即是热点设置中dhcp分配的。

    方法二:

    只在windows下,安装motorola的驱动

    http://www.motorola.com/staticfiles/Support/Experiences/Global_Drivers/USB_Drivers_bit_4.7.1.zip

    连接好usb后,选择usb连接模式是“摩托罗拉手机门户”

    在网络设置处,新建拨号,默认会选中Motorola usb modem,拨号号码为#777,用户名密码均为card,连接后电脑即可上网。

  • 思科交换机端口镜像

    公司要上IDS,所以要在交换机上将24端口做一个镜像,映射到23口上,并将IDS接到23口。

    monitor session 1 source interface Gi1/0/24
    monitor session 1 destination interface Gi1/0/23

  • H3C 5024P操作命令

    两种权限模式

    user-view和system-view,退出system-view输入quit或ctrl+z

    user-view可以进行的操作很小,可用的命令有:

     debugging Enable system debugging functions
     display Display current system information
     ping Ping function
     quit Exit from current command view
     reboot Reset switch
     reset Reset operation
     save Save current configuration   #保存当前配置到EEPROM
     system-view Enter the system view
     undo Cancel current setting

    进行配置基本上都在system-view下进行,可用的命令有:

     display Display current system information
     interface Specify the interface configuration view
     link-aggregation Ports aggregation mode
     mac-address Configure MAC address
     mirroring-port Specify mirroring port
     monitor-port Specify monitor port
     ping Ping function
     qos QOS configuration information
     queue-scheduler Specify queue scheduling mode and parameters
     quit Exit from current command view
     restore Restore configuration
     return Exit to user view
     super Modify super password parameters
     sysname Specify the host name
     storm-control Limit the rate of the specified packets of the switch
     snmp-agent Specify SNMP(Simple Network Management Protocol)
     configuration information
     undo Cancel current setting
     user-interface Enter user interface view
     vlan Configure VLAN

    system-view下修改密码

    super password bigadmin  这个是进入system-view及网页管理界面的密码
    set authentication password admin  这个是telnet的密码

    设置主机名

    sysname hostnameofswitch

    查看交换机运行信息

    [SW4_R2_R2]display version
     H3C S5024P Product Version S5024P-R0109
     Copyright (c) 2004-2009 Hangzhou H3C Technologies Co., Ltd. All rights Reserved.
     H3C S5024P uptime is 8 week(s),2 day(s),15 hour(s),17 minute(s)
    
     H3C S5024P with 17M 8051 Processor
     128K bytes SDRAM
     2048K bytes Flash Memory
     Config Register points to EEPROM
     Hardware Version is Ver.1.0
     Bootrom Version is 100
     [Subslot 0] 24 GE(4 COMBO) Hardware Version is Ver.1.0

    查看聚合信息

    display link-aggregation GigabitEthernet 0/21

    查看学习到的mac地址

    display mac-address

    设置snmp-agent信息

    snmp-agent community read abcdefg

    h3c s5024p重置交换机

    system-view下

    [H3C]restore default
    This will restore the default configuration in the EEPROM memory
    Are you sure?[Y/N]y
    *** Restoring to default configuration...
    *** Restore default configuration successfully!
    Reboot the switch to activate the default configuration!

    其他h3c交换机重置

    reset saved-configuration
    reboot
  • linux小命令

    enable -a显示当前用户可用的命令

    less -N abc.txt 显示行号

    ls 1>/dev/null 2>/dev/null 把标准输出和标准错误都定向到/dev/null

    ls >/dev/null 2>&1 将标准输出到/dev/null再把错误输出到1
    检查执行脚本的用户是不是为root
    if [ `id -u` -ne "0" ]; then
    echo "ERROR: This script must be run as root." 1>&2
    exit 1
    fi

    检查硬盘通电时间

    安装 smartmontools ,包含有smartctl命令,

    smartctl -A -v 9,msec24hour32 /dev/sda

    -v 9,msec24hour32表示将第9行显示的标准从毫秒转为小时

    结果是

    9 Power_On_Hours 0x0032 100 100 000 Old_age Always – 41h+37m+34.450s

    sftp使用不同于默认端口连接服务器

    sftp -oPort=222 [email protected]
  • cisco 2960s常用命令

    查看运行中的配置

    show running-config

    设备的型号,运行时间,固件

    show version

    其中

    Processor board ID 或 System serial number 为设备出厂时候的序列号

    show version | in uptime
    uptime is 12 weeks, 3 days, 20 hours, 17 minutes

    查看mac地址表

    show mac address-table

    查看具体的mac地址

    show mac address-table address 0008.00ff.fc04

    设置交换机的vlan ip信息,在configure terminal模式下

    ip address 192.168.8.222 255.255.255.0
    ip default-gateway 192.168.8.1

    查看当前路由器的时间

    show clock

    查看日志信息

    show log

    查看接口的信息,很全,后面可以接具体的项

    show interfaces
    show interfaces description查看接口up or down
    show interfaces status 快速查看接口

    查看cdp邻居

    show cdp neighbors

    查看vlan信息

    show vlan

    设置时间

    clock set 16:51:00 20 Aug 2013

    查看学习到的arp表

    show ip arp

    过滤,类似于grep

    show arp | include 0010.d1aa.0224

    查看内存情况,可以看到内存有70MB

    show processes memory
    
    Processor Pool Total:   73922040 Used:   26257284 Free:   47664756
    
    I/O Pool Total:   14680064 Used:   12235212 Free:    2444852
    
    Driver te Pool Total:    1048576 Used:         40 Free:    1048536
    

    查看 cpu 使用情况

    show processes cpu sorted
    CPU utilization for five seconds: 9%/0%; one minute: 9%; five minutes: 9%

    输出过多时,可以不折叠

    terminal length 0

    清理单条arp信息

    clear arp 10.10.0.249
    #clear arp ?
     A.B.C.D IP address             # 清理单条记录
     counters Clear ARP counters         #重置计数器
     interface Clear the entire ARP cache on the interface  # 清空整个arp缓存
     vrf Clear entries for a VPN Routing/Forwarding instance

    配置Telnet密码的过程如下.copy自:http://network.51cto.com/art/201007/212927.htm

    第1步,进入全局配置模式.

    Cisco# configure terminal

    第2步,输入Telnet进程号,进入Line配置模式.在一台交换机和路由器上,最多可以实现16个Telnet进程,方便多个用户同时查看和管理.”0 15″表明配置所有可能的16个进程.

    Cisco(config)# line vty 0 15

    第3步,指定Telnet密码.Telnet密码设置要求与Enable相同.

    Cisco(config)# password password

    第4步,返回特权模式.

    Cisco(config)# end

    第5步,保存配置Telnet密码最后的修改.

    Cisco# copy running-config startup-config

    改主机名也在configure terminal里

    hostname yourhostname