EVE-NG中思科交换机配置实例之聚合和ssh远程登录

本文详细介绍了在EVE-NG环境中进行链路聚合的配置步骤,包括设置主机名、配置VLAN接口IP地址、定义并配置聚合组、加入接口到聚合组及查看聚合状态。此外,还提供了交换机的SSH登录配置流程,如设置密码、生成密钥对、调整认证次数和超时时间等。
部署运行你感兴趣的模型镜像

配置环境:EVE-NG
拓扑:
在这里插入图片描述
///
#配置链路聚合
#设置主机名
Switch(config)#hostname hxjh1
#配置vlan接口ip地址
hxjh1(config)#interface vlan 1
hxjh1(config-if)#ip address 192.168.0.1 255.255.255.0
hxjh1(config)#interface vlan 2
hxjh1(config-if)#ip address 192.168.2.1 255.255.255.0
hxjh1(config-if)#no shutdown
#定义聚合组,配置聚合组
hxjh1(config)#interface port-channel 10
hxjh1(config-if)#description test
hxjh1(config-if)#switchport mode trunk
Command rejected: Po10 not a switching port.
hxjh1(config-if)#switchport trunk encapsulation dot1q
hxjh1(config-if)#switchport mode trunk
hxjh1(config-if)#switchport trunk allowed vlan all
hxjh1(config-if)#no shutdown
#接口加入聚合组
hxjh1(config)#interface e0/2
hxjh1(config-if)#no shutdown
hxjh1(config-if)#channel-group 10 mode active
#接口加入聚合组
hxjh1(config-if)#interface e0/3
hxjh1(config-if)#no shutdown
hxjh1(config-if)#channel-group 10 mode active
#查看聚合组状态
hxjh1# show etherchannel detail
///
///
#登录配置
#配置console口密码
hxjh1(config)#line console 0
hxjh1(config-line)#login
% Login disabled on line 0, until ‘password’ is set
hxjh1(config-line)#password admin
#配置enable密码
hxjh1(config)#enable secret admin
#配置本地用户登录方式
hxjh1(config)#line vty 0 4
hxjh1(config-line)#login local
#配置登录用户
hxjh1(config)#username admin privilege 15 secret admin
#配置本地域名
hxjh1(config)#ip domain-name test.com
#生成秘钥对
hxjh1(config)#crypto key generate rsa
#配置ssh登录认证次数
hxjh1(config)#ip ssh authentication-retries 3
#配置认证超时时间
hxjh1(config)#ip ssh time-out 120
#查看SSH状态信息
hxjh1#show ip ssh
SSH Enabled - version 1.5
Authentication timeout: 120 secs; Authentication retries: 3
///
///

#交换机1完整配置
hxjh1#show running-config
Building configuration...

Current configuration : 1269 bytes
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname hxjh1
!
boot-start-marker
boot-end-marker
!
!
enable secret 5 $1$N2IH$EJ46qTQz2G5PP1r834fr2.
!
username admin privilege 15 secret 5 $1$k3NR$tvKHhIm.5NY2yHOJ13IXB.
no aaa new-model
clock timezone EET 2
!
ip cef
ip domain-name test.com
!
no ipv6 cef
!
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
ip ssh version 1
!
!
!
!
!
!
interface Port-channel10
 description test
 switchport
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface Ethernet0/0
 duplex auto
!
interface Ethernet0/1
 duplex auto
!
interface Ethernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
 duplex auto
 channel-group 10 mode active
!
interface Ethernet0/3
 switchport trunk encapsulation dot1q
 switchport mode trunk
 duplex auto
 channel-group 10 mode active
!
interface Vlan1
 ip address 192.168.0.1 255.255.255.0
!
interface Vlan2
 ip address 192.168.2.1 255.255.255.0
!
!
ip forward-protocol nd
no ip http server
!
!
!
!
!
control-plane
!
!
line con 0
 password admin
 logging synchronous
 login
line aux 0
line vty 0 4
 login local
 transport input all
!
end

///
///

#交换机2完整配置
hxjh2#show running-config
Building configuration...

Current configuration : 1257 bytes
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname hxjh2
!
boot-start-marker
boot-end-marker
!
!
enable secret 5 $1$aPzQ$M7suR.LH9sTDB/dyr1TT8/
!
username admin privilege 15 secret 5 $1$KZID$jtdZKHRjhfEsn1diUXidQ.
no aaa new-model
clock timezone EET 2
!
ip cef
ip domain-name test.com
!
no ipv6 cef
!
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
vlan internal allocation policy ascending
!
ip ssh version 1
!
!
!
!
!
!
interface Port-channel10
 description test
 switchport
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface Ethernet0/0
 duplex auto
!
interface Ethernet0/1
 switchport access vlan 2
 switchport mode access
 duplex auto
!
interface Ethernet0/2
 switchport trunk encapsulation dot1q
 switchport mode trunk
 duplex auto
 channel-group 10 mode active
!
interface Ethernet0/3
 switchport trunk encapsulation dot1q
 switchport mode trunk
 duplex auto
 channel-group 10 mode active
!
interface Vlan1
 ip address 192.168.0.2 255.255.255.0
!
!
ip forward-protocol nd
no ip http server
!
!
!
!
!
control-plane
!
!
line con 0
 password admin
 logging synchronous
 login
line aux 0
line vty 0 4
 login
 transport input all
!
end

///
查看链路聚合:

hxjh2#show etherchannel summary
Flags:  D - down        P - bundled in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      N - not in use, no aggregation
        f - failed to allocate aggregator

        M - not in use, no aggregation due to minimum links not met
        m - not in use, port not aggregated due to minimum links not met
        u - unsuitable for bundling
        d - default port

        w - waiting to be aggregated
Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+-----------------------------------------------
10     Po10(SU)        LACP      Et0/2(P)       Et0/3(P)

验证ssh登录:

hxjh2#ssh -l admin 192.168.0.1
Password:

验证连通性:

VPCS> ping 192.168.0.1

84 bytes from 192.168.0.1 icmp_seq=1 ttl=255 time=0.335 ms
84 bytes from 192.168.0.1 icmp_seq=2 ttl=255 time=0.516 ms
84 bytes from 192.168.0.1 icmp_seq=3 ttl=255 time=4.029 ms
84 bytes from 192.168.0.1 icmp_seq=4 ttl=255 time=0.445 ms
84 bytes from 192.168.0.1 icmp_seq=5 ttl=255 time=1.579 ms

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

### 在Eve-NG中添加并配置思科交换机仿真设备 要在Eve-NG平台上安装配置思科交换机的仿真设备,需要利用Eve-NG中的Dynamips或IOU(Interconnection Operating Unit)组件。这些组件支持思科路由器交换机的仿真。以下是关于如何在Eve-NG中添加并配置思科交换机仿真设备的详细说明。 #### 1. 确保环境支持 首先,确保Eve-NG平台已正确安装,并且系统配置支持虚拟化技术(如KVM硬件加速)。如果使用的是基于Dynamips的思科交换机仿真,则需要确认Dynamips组件已正确安装并运行[^3]。 #### 2. 获取思科交换机镜像 思科交换机的仿真依赖于IOS镜像文件。需要从合法渠道获取适用于目标交换机型号的IOS镜像文件(通常为`.bin`格式)。将该镜像文件上传至Eve-NG服务器的适当目录,例如`/opt/unetlab/addons/dynamips/`[^1]。 #### 3. 配置交换机节点 在Eve-NG的图形界面中,执行以下操作: - 打开拓扑编辑器。 - 选择“Nodes”选项卡。 - 在节点列表中找到思科交换机的条目(通常标注为Cisco Switch或类似名称)。 - 单击以添加交换机节点到工作区。 #### 4. 设置交换机参数 双击新添加的交换机节点,进入其配置界面: - **Image Path**: 指定之前上传的IOS镜像文件路径。 - **RAM**: 根据交换机型号分配适当的内存大小(例如,128MB或256MB)。 - **NPE**: 选择合适的NPE(网络处理引擎)类型,通常为`npe-g2`。 - **Ethernet Adapters**: 配置以太网适配器的数量类型。例如,设置为`C3750-48P`表示48端口的以太网接口[^2]。 #### 5. 启动并初始化交换机 完成配置后,启动交换机节点。首次启动时,交换机会加载默认配置并提示进入初始设置模式。可以通过控制台访问交换机,执行如下命令进行基本配置: ```bash enable configure terminal hostname Switch1 interface GigabitEthernet0/1 no shutdown exit ``` #### 6. 测试网络连接 在拓扑图中将交换机与其他设备(如路由器或终端)连接。通过ping测试验证连通性,确保交换机正常工作。 --- ```python # 示例代码:自动化配置交换机的基本设置 from netmiko import ConnectHandler device = { 'device_type': 'cisco_ios', 'ip': '192.168.1.100', 'username': 'admin', 'password': 'password', } connection = ConnectHandler(**device) commands = [ 'configure terminal', 'hostname Switch1', 'interface GigabitEthernet0/1', 'no shutdown', 'exit', 'write memory' ] output = connection.send_config_set(commands) print(output) connection.disconnect() ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值