26-keychain配置
本章節下載: 26-keychain配置 (227.87 KB)
目 錄
keychain是加密規則(key)的集合,用來為應用程序提供動態認證功能。keychain在不中斷業務的前提下,通過定期更改用於認證的密鑰和算法來提升網絡數據傳輸的安全性。
一個keychain中的不同key可配置各自的認證密鑰、認證算法和生命周期。當係統時間處於key的生命周期內時,應用程序可以利用它對發送和接收的報文進行校驗。當keychain內各個key的生命周期具有連續性時,隨著係統時間的推移,各個key能夠依次生效,從而實現動態地更改應用程序使用的認證算法和認證密鑰。
keychain支持絕對時間模式和周期性時間模式,不同時間模式下,key的生命周期不同:
· 絕對時間模式:該模式的keychain中,key的生命周期是UTC(Coordinated Universal Time,國際協調時間)絕對時間,不受係統的時區和夏令時的影響。
· 周期性時間模式:該模式的keychain中,key的生命周期是根據係統的本地時間計算的,會受到係統的時區和夏令時的影響。包括以下四種模式:
¡ daily:按天的周期性時間模式,key的生命周期是從一天之內的指定起始時間到指定結束時間,每天重複。
¡ weekly:按周的周期性時間模式,key的生命周期是從一周之內的指定起始日到指定結束日,每周重複。
¡ monthly:按月的周期性時間模式,key的生命周期是從一月之內的指定起始日期到指定結束日期,每月重複。
¡ yearly:按年的周期性時間模式,key的生命周期是從一年之內的指定起始月到指定結束月,每年重複。
同一個keychain內的各個key使用send-lifetime指定的生命周期不可重疊,以確保在同一時刻,應用程序隻使用一個key對發送的報文進行校驗。
認證雙方在同一時間內所使用的key的認證算法和認證密鑰必須一致。
(1) 進入係統視圖。
system-view
(2) 創建keychain,並進入keychain視圖。
keychain keychain-name mode absolute
(3) (可選)配置TCP認證。
¡ 配置TCP增強認證選項中的類型值。
tcp-kind kind-value
缺省情況下,TCP增強認證選項中的類型值為254。
¡ 配置TCP認證算法對應的算法ID。
tcp-algorithm-id { hmac-md5 | hmac-sha-256 | hmac-sm3 | md5 | sm3 } algorithm-id
缺省情況下,MD5認證算法的算法ID是3,HMAC-MD5認證算法的算法ID是5,HMAC-SHA-256認證算法的算法ID是7,SM3認證算法的算法ID是51,HMAC-SM3認證算法的算法ID是52。
使用TCP作為傳輸層協議的通信雙方,類型值及相同的算法ID對應的認證算法必須一致。在與第三方設備互通時,請檢查類型值及算法ID的配置,確保兩端一致。
(4) (可選)延長key在報文接收時的生命周期。
accept-tolerance { value | infinite }
缺省情況下,沒有為keychain中的key延長其在報文接收時的生命周期。
用戶需要修改認證雙方的校驗信息時,可能會出現由於校驗信息的不匹配導致的業務中斷。為了避免上述情況的發生,可使用該命令為應用協議提供不中斷其業務的報文校驗服務。
(5) 創建一個key,並進入key視圖。
key key-id
(6) 配置key。
¡ 配置key的認證算法。
authentication-algorithm { hmac-md5 | hmac-sha-1 | hmac-sha-256 | hmac-sm3 | md5 | sm3 }
缺省情況下,未配置key的認證算法。
¡ 配置key的認證密鑰。
key-string { cipher | plain } string
缺省情況下,未配置key的認證密鑰。
¡ 配置用來校驗發送報文時key的UTC模式的生命周期。
send-lifetime utc start-time start-date { duration { duration-value | infinite } | to end-time end-date }
缺省情況下,未配置用來校驗發送報文時key的生命周期。
¡ 配置用來校驗接收報文時key的UTC模式的生命周期。
accept-lifetime utc start-time start-date { duration { duration-value | infinite } | to end-time end-date }
缺省情況下,未配置用來校驗接收報文時key的生命周期。
¡ (可選)將當前key指定為keychain的缺省發送key。
default-send-key
缺省情況下,keychain中不存在缺省發送key。
同一個keychain中,隻能將一個key指定為缺省的發送key。
(1) 進入係統視圖。
system-view
(2) 創建keychain,並進入keychain視圖。
keychain keychain-name mode periodic { daily | monthly | weekly | yearly }
(3) (可選)配置TCP認證。
¡ 配置TCP增強認證選項中的類型值。
tcp-kind kind-value
缺省情況下,TCP增強認證選項中的類型值為254。
¡ 配置TCP認證算法對應的算法ID。
tcp-algorithm-id { hmac-md5 | hmac-sha-256 | hmac-sm3 | md5 | sm3 } algorithm-id
缺省情況下,MD5認證算法的算法ID是3,HMAC-MD5認證算法的算法ID是5,HMAC-SHA-256認證算法的算法ID是7,SM3認證算法的算法ID是51,HMAC-SM3認證算法的算法ID是52。
使用TCP作為傳輸層協議的通信雙方,類型值及相同的算法ID對應的認證算法必須一致。在與第三方設備互通時,請檢查類型值及算法ID的配置,確保兩端一致。
(4) (可選)為keychain中的key延長其在報文接收時的生命周期。
accept-tolerance { value | infinite }
缺省情況下,沒有為keychain中的key延長其在報文接收時的生命周期。
用戶需要修改認證雙方的校驗信息時,可能會出現由於校驗信息的不匹配導致的業務中斷。使用本命令可避免上述情況的發生。
(5) 創建一個key,並進入key視圖。
key key-id
(6) 配置key。
¡ 配置key的認證算法。
authentication-algorithm { hmac-md5 | hmac-sha-1 | hmac-sha-256 | hmac-sm3 | md5 | sm3 }
缺省情況下,未配置key的認證算法。
¡ 配置key的認證密鑰。
key-string { cipher | plain } string
缺省情況下,未配置key的認證密鑰。
¡ 配置用來校驗發送報文時key的周期性時間模式的生命周期。請選擇其中一項進行配置。
send-lifetime daily start-day-time to end-day-time
send-lifetime date { month-day&<1-31> | start-month-day to end-month-day }
send-lifetime day { week-day | start-week-day to end-week-day }
send-lifetime month { month | start-month to end-month }
缺省情況下,未配置用來校驗發送報文時key的生命周期。
¡ 配置用來校驗接收報文時key的周期性時間模式的生命周期。請選擇其中一項進行配置。
accept-lifetime daily start-day-time to end-day-time
accept-lifetime date { month-day&<1-31> | start-month-day to end-month-day }
accept-lifetime day { week-day | start-week-day to end-week-day }
accept-lifetime month { month | start-month to end-month }
缺省情況下,未配置用來校驗接收報文時key的生命周期。
¡ (可選)將當前key指定為keychain的缺省發送key。
default-send-key
缺省情況下,keychain中不存在缺省發送key。
同一個keychain中,隻能將一個key指定為缺省的發送key。
在完成上述配置後,在任意視圖下執行display命令可以顯示配置後keychain的運行情況,通過查看顯示信息驗證配置的效果。
表1-1 keychain顯示和維護
操作 |
命令 |
顯示keychain信息 |
display keychain [ name keychain-name [ key key-id ] ] |
Device A和Device B之間建立OSPF鄰居,使用keychain認證方式對發送和接收的報文進行校驗。具體要求為:Device A和Device B的keychain中創建key 1和key 2,key 1的生命周期結束後,自動切換成key 2來對報文進行校驗。
圖1-1 keychain配置組網圖
(1) 配置接口IP地址、路由、安全域及域間策略保證網絡可達,具體配置步驟略。
(2) 配置Device A
# 配置接口的IP地址(略)。
# 配置OSPF基本功能。
<DeviceA> system-view
[DeviceA] ospf 1 router-id 1.1.1.1
[DeviceA-ospf-1] area 0
[DeviceA-ospf-1-area-0.0.0.0] network 192.1.1.0 0.0.0.255
[DeviceA-ospf-1-area-0.0.0.0] quit
[DeviceA-ospf-1] quit
# 配置名稱為abc的keychain,並指定其工作於絕對時間模式。
[DeviceA] keychain abc mode absolute
# 在keychain abc中創建key 1和key 2,並配置其認證算法、認證密鑰和生命周期。
[DeviceA-keychain-abc] key 1
[DeviceA-keychain-abc-key-1] authentication-algorithm md5
[DeviceA-keychain-abc-key-1] key-string plain 123456
[DeviceA-keychain-abc-key-1] send-lifetime utc 10:00:00 2015/02/06 to 11:00:00 2015/02/06
[DeviceA-keychain-abc-key-1] accept-lifetime utc 10:00:00 2015/02/06 to 11:00:00 2015/02/06
[DeviceA-keychain-abc-key-1] quit
[DeviceA-keychain-abc] key 2
[DeviceA-keychain-abc-key-2] authentication-algorithm hmac-md5
[DeviceA-keychain-abc-key-2] key-string plain pwd123
[DeviceA-keychain-abc-key-2] send-lifetime utc 11:00:00 2015/02/06 to 12:00:00 2015/02/06
[DeviceA-keychain-abc-key-2] accept-lifetime utc 11:00:00 2015/02/06 to 12:00:00 2015/02/06
[DeviceA-keychain-abc-key-2] quit
[DeviceA-keychain-abc] quit
# 配置接口GigabitEthernet1/0/1使用keychain認證方式。
[DeviceA] interface gigabitethernet 1/0/1
[DeviceA-GigabitEthernet1/0/1] ospf authentication-mode keychain abc
[DeviceA-GigabitEthernet1/0/1] quit
(3) 配置Device B
# 配置接口的IP地址(略)。
# 配置OSPF基本功能。
<DeviceB> system-view
[DeviceB] ospf 1 router-id 2.2.2.2
[DeviceB-ospf-1] area 0
[DeviceB-ospf-1-area-0.0.0.0] network 192.1.1.0 0.0.0.255
[DeviceB-ospf-1-area-0.0.0.0] quit
[DeviceB-ospf-1] quit
# 配置名稱為abc的keychain,並指定其工作於絕對時間模式。
[DeviceB] keychain abc mode absolute
# 在keychain abc中創建key 1和key2,並配置其認證算法、認證密鑰和生命周期。
[DeviceB-keychain-abc] key 1
[DeviceB-keychain-abc-key-1] authentication-algorithm md5
[DeviceB-keychain-abc-key-1] key-string plain 123456
[DeviceB-keychain-abc-key-1] send-lifetime utc 10:00:00 2015/02/06 to 11:00:00 2015/02/06
[DeviceB-keychain-abc-key-1] accept-lifetime utc 10:00:00 2015/02/06 to 11:10:00 2015/02/06
[DeviceB-keychain-abc-key-1] quit
[DeviceB-keychain-abc] key 2
[DeviceB-keychain-abc-key-2] key-string plain pwd123
[DeviceB-keychain-abc-key-2] authentication-algorithm hmac-md5
[DeviceB-keychain-abc-key-2] send-lifetime utc 11:00:00 2015/02/06 to 12:00:00 2015/02/06
[DeviceB-keychain-abc-key-2] accept-lifetime utc 11:00:00 2015/02/06 to 12:00:00 2015/02/06
[DeviceB-keychain-abc-key-2] quit
[DeviceB-keychain-abc] quit
# 配置接口GigabitEthernet1/0/1使用keychain驗證模式。
[DeviceB] interface gigabitethernet 1/0/1
[DeviceB-GigabitEthernet1/0/1] ospf authentication-mode keychain abc
[DeviceB-GigabitEthernet1/0/1] quit
(1) 當係統時間處於2015/02/06的10:00:00到11:00:00時,通過查看以下信息來確認keychain的運行狀態。
# 查看Device A的keychain信息,發現key 1為有效key。
[DeviceA] display keychain
Keychain name : abc
Mode : absolute
Accept tolerance : 0
TCP kind value : 254
TCP algorithm value
HMAC-MD5 : 5
HMAC-SHA-256 : 7
MD5 : 3
HMAC-SM3 : 52
SM3 : 51
Default send key ID : None
Active send key ID : 1
Active accept key IDs: 1
Key ID : 1
Key string : $c$3$dYTC8QeOKJkwFwP2k/rWL+1p6uMTw3MqNg==
Algorithm : md5
Send lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Send status : Active
Accept lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Accept status : Active
Key ID : 2
Key string : $c$3$7TSPbUxoP1ytOqkdcJ3K3x0BnXEWl4mOEw==
Algorithm : hmac-md5
Send lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Send status : Inactive
Accept lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Accept status : Inactive
# 查看Device B的keychain信息,發現key 1為有效key。
[DeviceB]display keychain
Keychain name : abc
Mode : absolute
Accept tolerance : 0
TCP kind value : 254
TCP algorithm value
HMAC-MD5 : 5
HMAC-SHA-256 : 7
MD5 : 3
HMAC-SM3 : 52
SM3 : 51
Default send key ID : None
Active send key ID : 1
Active accept key IDs: 1
Key ID : 1
Key string : $c$3$/G/Shnh6heXWprlSQy/XDmftHa2JZJBSgg==
Algorithm : md5
Send lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Send status : Active
Accept lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Accept status : Active
Key ID : 2
Key string : $c$3$t4qHAw1hpZYN0JKIEpXPcMFMVT81u0hiOw==
Algorithm : hmac-md5
Send lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Send status : Inactive
Accept lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Accept status : Inactive
(2) 當係統時間處於2015/02/06的11:10:00到12:00:00時,通過查看以下信息來確認keychain的運行狀態。
# 查看Device A的keychain信息,發現key 2為有效key。
[DeviceA]display keychain
Keychain name : abc
Mode : absolute
Accept tolerance : 0
TCP kind value : 254
TCP algorithm value
HMAC-MD5 : 5
HMAC-SHA-256 : 7
MD5 : 3
HMAC-SM3 : 52
SM3 : 51
Default send key ID : None
Active send key ID : 2
Active accept key IDs: 2
Key ID : 1
Key string : $c$3$dYTC8QeOKJkwFwP2k/rWL+1p6uMTw3MqNg==
Algorithm : md5
Send lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Send status : Inactive
Accept lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Accept status : Inactive
Key ID : 2
Key string : $c$3$7TSPbUxoP1ytOqkdcJ3K3x0BnXEWl4mOEw==
Algorithm : hmac-md5
Send lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Send status : Active
Accept lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Accept status : Active
# 查看Device B的keychain信息,發現key 2為有效key。
[DeviceB]display keychain
Keychain name : abc
Mode : absolute
Accept tolerance : 0
TCP kind value : 254
TCP algorithm value
HMAC-MD5 : 5
HMAC-SHA-256 : 7
MD5 : 3
HMAC-SM3 : 52
SM3 : 51
Default send key ID : None
Active send key ID : 1
Active accept key IDs: 1
Key ID : 1
Key string : $c$3$/G/Shnh6heXWprlSQy/XDmftHa2JZJBSgg==
Algorithm : md5
Send lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Send status : Inactive
Accept lifetime : 10:00:00 2015/02/06 to 11:00:00 2015/02/06
Accept status : Inactive
Key ID : 2
Key string : $c$3$t4qHAw1hpZYN0JKIEpXPcMFMVT81u0hiOw==
Algorithm : hmac-md5
Send lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Send status : Active
Accept lifetime : 11:00:00 2015/02/06 to 12:00:00 2015/02/06
Accept status : Active
不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!