- 拓扑图如下

- 打开接口
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#sh
Router(config)#int
Router(config)#interface gi
Router(config)#interface gigabitEthernet 0/0/0
Router(config-if)#no sh
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0, changed state to up
Router(config-if)#
Router(config-if)#exit
Router(config)#interface gigabitEthernet 0/0/1
Router(config-if)#no sh
Router(config-if)#no shutdow
Router(config)#interface g
Router(config)#interface gigabitEthernet 0/0/0
Router(config-if)#no sh
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0, changed state to up
Router(config-if)#
Router(config-if)#
Router(config-if)#exit
Router(config)#int
Router(config)#interface gi
Router(config)#interface gigabitEthernet 0/0/1
Router(config-if)#no sh
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/1, changed state to up

- 查看C D P 配置

- 查看C D P 邻居


- 关闭、启动C D P , 调整C D P 参数
R 1 ( c o n f i g ) # i n t g 0 / 0
R 1 ( c o n f i g – i f ) # n o c d p e n a b l e
/ /以上是在g 0 / 0 接口上关闭c d p, 其他接口还运行C D P
R 1 ( c o n f i g – i f ) # e x i t
R 1 ( c o n f i g ) # n o c d p r u n / /以上是在整个路由器上关闭C D P
R 1 ( c o n f i g ) # c d p r u n / /在整个路由器上打开C D P
R 1 ( c o n f i g ) # c d p t i m e r 3 0 / / C D P 消息发送时间为3 0 s
R 1 ( c o n f i g ) # c d p h o l d t i m e 1 2 0
/ /调整C D P 消息的h o l d t i m e 为1 2 0 s, 对方收到该路由器发送的C D P 消息后将保持1 2 0 s
R 1 # s h o w c d p
G l o b a l C D P i n f o r m a t i o n ;
S e n d i n g C D P p a c k e t s e v e r y 3 0 s e c o n d s
S e n d i n g a h o l d t i m e v a l u e o f 1 2 0 s e c o n d s
S e n d i n g C D P v 2 a d v e r t i s e m e n t s i s e n a b l e d
R0(config)#int
R0(config)#interface gi
R0(config)#interface gigabitEthernet gi
R0(config)#interface gigabitEthernet 0/0/0
R0(config-if)#
R0(config-if)#no cdp en
R0(config-if)#no cdp enable
R0(config-if)#exit
R0(config)#no cdp run
R0(config)#exit
R0#
%SYS-5-CONFIG_I: Configured from console by console
R0#sho
R0#show cdp nei
R0#show cdp neighbors
% CDP is not enabled