实验一口令和主机名设置1.交换机的初始化当交换机没有进行配置时,接入超级终端会提示是否以对话方式进行配置,初始化内容主要有IP地址、网关、主机名和口令等。
配置文件是flash:config.text。
2924交换机进入ROM方式是在上电时按住其mode键,本软件是按Ctrl+Break键,出现:switch> ;按Ctrl+Break键switch:reset ;或用boot命令如果有配置文件进入用户模式,否则提交对话:--- System Configuration Dialog ---At any point you may enter a question mark '?' for help.Use ctrl-c to abort configuration dialog at any prompt.Default settings are in square brackets '[]'.Continue with configuration dialog? [yes/no]:yEnter IP address:10.65.1.8Enter IP netmask:255.255.0.0Would you like to enter a default gateway address? [yes]:IP address of default gateway:Enter host name [Switch]:swaThe enable secret is a one-way cryptographic secret used instead of the enable password when it exists.Enter enable secret:aaaWould you like to configure a Telnet password? [yes]:Enter Telnet password:aWould you like to enable as a cluster command switch? [no]:The following configuration command script was created:......Press RETURN to get started.swa>enpassword:aaaswa#copy run start (保存配置信息)swa#dir flash: (查看闪存中的文件)再次进入对话方式:swa#setup2.路由器的初始化(路由器初始化与交换机类似)router> ;用户模式,按Ctrl+Break rommon>reset ;进入ROM监控状态,复位引导Continue with configuration dialog? [yes/no]:yesAt any point you may enter a question mark '?' for help.Use ctrl-c to abort configuration dialog at any prompt.Default settings are in square brackets '[ ]'.Would you like to enter basic management setup? [yes/no]:yesConfiguring global parameters:Enter host name [router]:ra回车The enable secret is a password used to protect access toprivileged EXEC and configuration modes. This password,after entered,becomes encrypted in the configuration.Enter enable secret:aaa回车The enable password is used when you do not specify anenable secret password,with some older software versions,and some boot images.Enter enable password:aa回车The virtual terminal password is used to protectaccess to the router over a network interface.Enter virtual terminal password :a回车Enter interface name used to connect to the managementnetwork from the above interface summary:FastEthernet0/0回车Configuring interface FastEthernet0/0:回车Use the 100 Base-TX (RJ-45) connector? [yes]:回车Operate in full-duplex mode? [no]:回车Configure IP on this interface? [yes]:回车IP address for this interface [ ]:10.1.1.1回车Subnet mask for this interface [ ]:255.0.0.0回车[0] Go to the IOS command prompt without saving this config.[1] Return back to the setup without saving this config.[2] Save this configuration to nvram and exit.Enter your selection [2]:回车ra>enpassword aaa (进入特权模式)ra#show run (显示配置信息)ra#w (保存配置信息)ra#dir flash: (显示配置文件)(配置文件在2621路由器不能删除,放弁配置文件要用寄存器设置0x2142);3. 用命令行设置交换机和路由器的口令和主机名先对交换机进行操作,双击SwitchA,出现:switch>en ;第一次密码为空switch#conf t ;进入全局配置模式switch(config)#hostname swa ;设置交换机名swa(config)#enable secret aaa ;设置特权加密口令为aaaswa(config)#enable password aax ;设置特权非密口令为aaxswa(config)#line console 0 ;进入控制台口(Rs232)swa(config-line)#password aa ;设置console登录口令为aaswa(config-line)#login ;登录要求口令验证swa(config-line)#line vty 0 4 ;进入虚拟终端virtual ttyswa(config-line)#password a ;设置vty的登录口令为aswa(config-line)#login ;登录要求口令验证swa(config-line)#exit ;返回上一层swa(config)#exit ;返回上一层swa#sh run ;看配置信息swa#exit ;返回命令swa>enpassword: ;请问输入哪个口(aaa)secret是设置加密口令,一般都使用这种口令设置方式,它优先级高,即没设置secret 口令时,非加密口令才有效。
4. 备份IOS和配置文件在实际工作中经常需要备份路由器的IOS和配置文件,以备系统有问题时的恢复。
可以这样操作:router#dir nvram:router#copy flash:c2621.bin tftp:router#copy startup-config tftp:router#实验二计算机与交换机IP地址设置1. 双击HostA,输入用户名和口令。
PCA login:rootPassword:linux[root#PCA root]# ifconfig eth0 10.65.1.1 netmask 255.255.0.0 设置IP[root#PCA root]# ifconfig 查看IP[root#PCA root]# ifconfig eth0 10.65.1.1 netmask 255.255.0.0 down关闭网卡[root#PCA root]# route add default gw 10.65.1.9 设置网关[root#PCA root]# route 查看网关[root#PCA root]# route del default gw 10.65.1.9 删除网关2. 双击HostB,输入用户名和入口令,键入"?"可以求得帮助。
PCB login:rootPassword:linux[root#PCB root]# ifconfig eth0 10.65.1.2 netmask 255.255.0.0 设置IP[root#PCB root]# ifconfig[root#PCB root]# route add default gw 10.65.1.9 设置网关[root#PCB root]# route这里只是说明设置网关的方法,关于它的意义在后面实现才能体现。
[root@PCA root]# ping 10.65.1.1 (通) [root@PCB root]# ping 10.65.1.1 (通)[root@PCA root]# ping 10.65.1.2 (通) [root@PCB root]# ping 10.65.1.2 (通) 可见交换机不用做任何设置,就可以让两个计算机连通。
交换机默认状态是所有端口全在vlan1,可以替代HUB使用,交换机的端口独享带宽。
3.双击SwitchAswitch>en 进入特权模式switch#conf t 进入全局配置模式:switch(config)#int vlan 1进入默认vlan状态:switch(config-if)#ip address 10.65.1.3 255.255.0.0 设置ip地址和掩码:switch(config)#ip default-gateway 10.65.1.9 设置switch的网关:switch#sh run查看当前配置:测试联通情况:switch#ping 10.65.1.1 (通) ;ping HostAswitch#ping 10.65.1.2 (通) ;ping HostBswitch#ping 10.65.1.3 (通) ;ping自己switch#ping 10.65.1.4 (不通) ;没有这个IP,所以不通。