思科网络设备配置命令
思科网络设备常用配置命令
一、 VLAN 配置
1、添加VLAN
vlan database //VLAN数据库模式
vlan name
真实设备还可以采用全局模式添加VLAN :
config terminal
vlan
name
2、分配接口
interface range f0/m – n
switchport mode access
switchport access vlan
3、查看配置
show vlan brief
show vlan id
二、 中继配置
1、 配置Trunk
interface f0/m
switchport mode trunk
switchport trunk encapsulation { isl | dot1q | negotiate } //配封装方式,可不配
2、 查看接口模式
show interface f0/m switchport
三、 VTP 配置
vtp domain //创建VTP 域
vtp mode { server | client | transparent } //配VTP 模式
vtp password //配VTP 口令
show vtp status //查看配置
四、 以太网通道配置
interface range f0/m – n
channel-protocol {pagp | lacp} //可以不配
channel-group mode on
五、 STP 配置
spanning-tree vlan root { primary | secondary } //配为主或次根网桥 spanning-tree vlan priority //配优先级,越小越优先
show spanning-tree //查看STP
六、 三层交换机配置,实现VLAN 互通
ip routing //启动路由
interface vlan //配置VLAN 的IP 地址
ip address
no shutdown
interface f0/m //配f0/m为路由接口
no switchport
七、 静态路由与默认路由配置
ip route //静态路由
ip route 0.0.0.0 0.0.0.0 //默认路由
八、 单臂路由配置
int f0/x
no shutdown (模拟设备小凡用no switchport)
int f0/x.1
encapsulation dot1q
ip address
九、 RIP 协议配置
router rip
version {1 | 2} //选择版本,默认为版本1
no auto-summary //关闭路由汇总
network //宣告网段
redistribute ospf //重分发OSPF 路由协议
十、 OSPF 协议配置
router ospf
network area
redistribute rip //路由重分发
十一、 HSRP 配置
interface f0/m
standby ip //配为HSRP 成员
standby priority //配优先级,高的为活跃路由器
standby preempt //配占先权
十二、 访问控制列表
1、 标准ACL
access-list permit | deny
interface f0/m
ip access-group {in | out }
2、 扩展ACL
access-list {permit | deny} eq 端口
3、 命名ACL
ip access-list {standard| extend }
permit | deny
{permit | deny} eq 端口
4、 定时ACL
time-range
periodic hh:mm to hh:mm //定义一个时间周期
absolute [start hh:mm 日 月 年] [ end hh:mm 日 月 年 ] //定义绝对时间
access-list {permit | deny} eq 端口 time-range //配ACL 时引入时间范围
十三、 网络地址转换
1、 静态NAT
ip nat inside soure static
interface f0/m //内部端口启用NAT
ip nat inside
interface s1/n //外部端口启用NAT
ip nat outside
2、 动态NAT
access-list permit | deny
ip nat pool netmask
ip nat inside soure list pool [overload] //配地址复用加overload 十四、 PPP 认证
1、PAP 认证
interface serial 0/0
encapsulation ppp
ip address
主认证方:
username user_name password 0 pass_word
ppp authentication pap
被认证方:
配置认证用户名和密码
Router(config-if)# ppp pap sent-username user_name password 0 pass_word
2、CHAP 认证
主认证方:
配置认证用户名和密码
Router(config)# username user_name password 0 pass_word
启用CHAP 认证
Router(config-if)# ppp authentication chap
配置认证用的用户名
Router(config-if)# ppp chap hostname user_name
被认证方:
配置认证用户名和密码
Router(config)# username user_name password 0 pass_word
配置认证用的密码
Router(config-if)# ppp chap password 0 pass_word
优先使用username 设置的密码; 没有再用ppp chap设置的。
配置认证用的用户名
Router(config-if)# ppp chap hostname user_name