交换机

1.声明vlan andvlan分配IP
vlan [
编号] //vlan 10

Sw I e 0/0/[编号-编号] //sw I e 0/0/1-10s
in vlan [
编号] //in vlan 10
ip add [IP
地址] [子网掩码] //ip add 192.168.1.1 255.255.255.0

2.静态路由

Ip route 0.0.0.0 0.0.0.0 [下一跳IP] //ip route 0.0.0.0 0.0.0.0 192.168.1.2

3.RIP协议路由

Vlan方法

Routerrip

Network [自己的vlan] //network vlan 10

IP方法

Router rip

Network [ip ]

4.ospf协议路由

Vlan方法

Router ospf

Int vlan [编号] //int vlan 10

Ip ospf enable area [编号] //ip ospf enable area 0

IP方法

Router ospf

Network [自己的IP]/[网关] area0 //network 192.168.1.1/24 area 0

5.telnet开启

telnet-server enable

telnet-user [用户] password 0[密码]

6.stp生成树协议

spanning-tree mode stp

7.链路聚合(手工)

spanning-tree modemstp //开启mstp生成树协议

port-group [编号] // port-group 1

int e 0/0/[做链路的那几个端口号] //int 0/0/1-2

port-group [编号] modeon // port-group 1 mode on

8. 链路聚合(LACP动态生成)

spanning-tree mode mstp

port-group [编号]

(交换机A的配置)port-group [编号] mode active

(交换机B的配置)port-group [编号] mode passive

9.trunk

Int e 0/0/[端口]

Sw modetrunk //设置为trunk

Sw trunk allowed vlanall //划分到所有vlan

10Mac地址和端口绑定(单个)

Inte 0/0/[端口]

Swport-security

swport-security mac-address [mac地址]

11.Mac地址和端口绑定(多个)

Int e 0/0/[端口]

Sw port-security maximum [安全mac地址个数如:3]

swport-security mac-address [mac地址]

swport-security mac-address [mac地址]

swport-security mac-address [mac地址]

12.Mac地址和端口绑定(动态学习)

Int e 0/0/[端口]

Sw port-security maximum

Sw port-security maximum lock

Sw port-security maximum convert

13.mac地址表绑定

mac-address-table static address [mac地址] vlan [编号] int e0/0/[编号]

//解释: mac地址只能在指定vlan中的指定端口中使用,其他的都不能使用(未测试)

14.mac地址过滤

mac-address-table blackhole address [mac地址] vlan [编号]

//解释: mac地址在指定vlan中不能使用(未测试)

15.am来绑定ipmac

Am enable

Int e 0/0/[端口]

Am mac-ip-pool [mac地址] [IP地址]

//验证方法: showam

//解锁:no am port

16.dhcp配置

Service dhcp

Ip dhcp pool [地址池名]

Network-address [IP段如:192.168.1.0][掩码数如:24]

Lease [租用天数]

Default-router [网关IP]

Dns-server [DNS IP]

17.ACLIP访问控制

Ip access-list standard test

Deny 192.168.1.100.0 0.0.0.0.255 //禁止IP段访问

Deny 192.168.200.11 0.0.0.0 //禁止单个IP访问

Deny tcp 192.168.200.0 0.0.0.255any-destination d-port23 //拒绝IPtelnet数据

Permit 192.168.1.100.0 0.0.0.0.255 //允许IP段访问

Deny 192.168.200.11 0.0.0.0 //允许IP访问

//下面2条是开启ACL

Firewall enable

Firewalldefault permit

//绑定ACL到各个端口

Int e 0/0/[端口]

Ip access-group test in

//验证方法

Show access-group

18.web管理

Ip httpsever //开启web服务

Web-user [用户名] password 0[密码] //添加管理用户



路由器

1. 进入端口给端口分配IP

a) Int [段口]

b) Ip add [ip] [子网掩码]

c) No shu

2.静态路由

Ip route 0.0.0.0 0.0.0.0 [下一跳IP] //ip route 0.0.0.0 0.0.0.0 192.168.1.2

3.RIP协议路由

Router rip

Network [ip ]

4.ospf协议路由

Router ospf [进程号如:1]

Network [自己的IP] [子网掩码] area [区域号如:0]

5.telnet开启

Username [用户名]password [密码]

Aaa authentication login [用户名] local

Line vty 0 4

Login authentication [刚刚那个用户名]



6.ppp协议

Enc ppp

7.时钟平率

Ph sp 64000

8.web访问

Username [用户]password 0 [密码] //添加用户

ip http webm-type [web配置方式] //选择方式.高级,典型,向导

ip http port [端口] //配置web端口


9.hdlc

//PPP差不多,都在端口中配置

Enc hdlc


10.dhcp

Ip dhcp pool [地址池名如:1]

Network 192.168.2.0255.255.255.0 //定义网络段

Range 192.168.2.10 192.168.2.20 //定义地址范围

Default-router[IP] //配置网关

Dns-sever[ip] //配置NDSIP

Lease [天数] //租用天数

//退回配置模式(config)

Ip dhcpdenable //开启dhcp


11.nat

Router-A_config#Ip access-list standard [访问控制名如:1] //定义访问控制列表

Router-A_config_sta_nacl#Permit [IP ] [子网掩码] //定义允许转换的源地址范围

//:permit192.168.10.0 255.255.255.0

Router-A_config#ip nat pool [转换地址池名如:xh] [起始IP][结束IP] [子网掩码]

Router-A_config#ip nat inside soure list [刚刚定义的访问控制名] pool [刚刚转换地址池名]overload

//配置将ACL允许的源地址转换成overld 中的地址,并且做pat复用地址

Router-A_config#int f0/0

Router-A_config_f0/0#ip natinside //定义内部接口

Router-A_config# int s0/2

Router-A_config_ s0/2#ip natoutside //定义外部接口


12.vpn(L2TP/PPTP)的配置 //AB的数据传输实例

ROUTER-A的配置

Int virtual-tunnel 0

Ip add 172.16.1.2 255.255.255.0

Ppp chap host test@dcn.net

Ppp chap password [密码]

//退回配置模式(config)

Vpdn enable

Vpdn-group 0

Request-dialin

Initiate-to ip 192.168.1.2 priority 1

Protocol 12tp

Domain dcn.net

//退回配置模式(config)

Ip route 192.168.2.0 255.255.255.0 virtual-tunel 0

ROUTER-B的配置