拓撲如下

簡單認證
R1
enable 進入特權模式
config 進入全局模式
hostname R1 修改名稱
interface s0/1 進入端口
ip aadress 192.168.1.1 255.255.255.0 設置IP地址
physical-layer speed 64000 設置同步時鍾
interface l0 進入端口
ip address 192.168.2.254 255.255.255.0 設置IP地址
exit 返回上一級
router ospf 1 啟動OSPF協議
network 192.168.1.0 255.255.255.0 area 0 添加直連網段到OSPF
network 192.168.2.0 255.255.255.0 area 0 添加直連網段到OSPF
interface s0/1 進入端口
ip ospf authentication simple 啟動OSPF端口簡單認證
ip ospf password 978285 設置簡單認證密碼
R2
enable 進入特權模式
config 進入全局模式
hostname R1 修改名稱
interface s0/1 進入端口
ip aadress 192.168.1.2 255.255.255.0 設置IP地址
physical-layer speed 64000 設置同步時鍾
interface l0 進入端口
ip address 192.168.3.254 255.255.255.0 設置IP地址
exit 返回上一級
router ospf 1 啟動OSPF協議
network 192.168.1.0 255.255.255.0 area 0 添加直連網段到OSPF
network 192.168.3.0 255.255.255.0 area 0 添加直連網段到OSPF
interface s0/1 進入端口
ip ospf authentication simple 啟動OSPF端口簡單認證
ip ospf password 978285 設置簡單認證密碼
MD5認證
R1
enable 進入特權模式
config 進入全局模式
hostname R1 修改名稱
interface s0/1 進入端口
ip aadress 192.168.1.1 255.255.255.0 設置IP地址
physical-layer speed 64000 設置同步時鍾
interface l0 進入端口
ip address 192.168.2.254 255.255.255.0 設置IP地址
exit 返回上一級
router ospf 1 啟動OSPF協議
network 192.168.1.0 255.255.255.0 area 0 添加直連網段到OSPF
network 192.168.2.0 255.255.255.0 area 0 添加直連網段到OSPF
interface s0/1 進入端口
ip ospf authentication message-digest 啟動OSPF端口MD5認證
ip ospf message-digest-key 1 md5 978285 設置MD5認證密碼
R2
enable 進入特權模式
config 進入全局模式
hostname R1 修改名稱
interface s0/1 進入端口
ip aadress 192.168.1.1 255.255.255.0 設置IP地址
physical-layer speed 64000 設置同步時鍾
interface l0 進入端口
ip address 192.168.3.254 255.255.255.0 設置IP地址
exit 返回上一級
router ospf 1 啟動OSPF協議
network 192.168.1.0 255.255.255.0 area 0 添加直連網段到OSPF
network 192.168.3.0 255.255.255.0 area 0 添加直連網段到OSPF
interface s0/1 進入端口
ip ospf authentication message-digest 啟動OSPF端口MD5認證
ip ospf message-digest-key 1 md5 978285 設置MD5認證密碼
相關命令
基於端口的簡單認證
ip ospf authentication simple 在相應端口啟動簡單認證
ip ospf password [密碼] 在相應端口設置認證密碼
基於端口的MD5認證
ip ospf authentication message-digest 在相應端口啟動認證
ip ospf message-digest-key [keyID] md5 [密碼] 在相應端口設置keyID以及認證密碼
