1. 按v进入visual状态,选择多行,用>或<缩进或缩出
2. 自动缩进排版,相当于code format
当前行用== (连按=两次)
对多行用n==(n是自然数)表示自动缩进从当前行起的下面n行。
先使用gg使光标跳到第一行行首,再按=G可对整篇代码进行排版。
1. 按v进入visual状态,选择多行,用>或<缩进或缩出
2. 自动缩进排版,相当于code format
当前行用== (连按=两次)
对多行用n==(n是自然数)表示自动缩进从当前行起的下面n行。
先使用gg使光标跳到第一行行首,再按=G可对整篇代码进行排版。
进入配置模式
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
我这里使用的是上海电信的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
两种权限模式
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
enable -a显示当前用户可用的命令
less -N abc.txt 显示行号
ls 1>/dev/null 2>/dev/null 把标准输出和标准错误都定向到/dev/null
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]