本文于 108 天前发布,最后更新于 108 天前
原始 MAC 地址文件
[root@dameng linuxscript]# cat maclist D7:53:20:B3:E3:FE 1E:91:79:0D:B1:DB 4E:B0:1A:0D:11:D2 BF:59:7F:40:EF:6E 02:2D:F7:1A:90:EF 01:C6:16:66:B8:75 3F:09:9C:35:C4:B8 A0:B2:AC:30:04:31 D9:5D:1D:12:98:7A 9A:EE:FA:CD:39:90
首先,去掉冒号(准备工作)
[root@dameng linuxscript]# sed 's/://g' maclist D75320B3E3FE 1E91790DB1DB 4EB01A0D11D2 BF597F40EF6E 022DF71A90EF 01C61666B875 3F099C35C4B8 A0B2AC300431 D95D1D12987A 9AEEFACD3990
IEEE 格式
[root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(..\)/\1-/g;s/-$//' D7-53-20-B3-E3-FE 1E-91-79-0D-B1-DB 4E-B0-1A-0D-11-D2 BF-59-7F-40-EF-6E 02-2D-F7-1A-90-EF 01-C6-16-66-B8-75 3F-09-9C-35-C4-B8 A0-B2-AC-30-04-31 D9-5D-1D-12-98-7A 9A-EE-FA-CD-39-90
华为交换机格式
[root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(....\)/\1-/g;s/-$//' D753-20B3-E3FE 1E91-790D-B1DB 4EB0-1A0D-11D2 BF59-7F40-EF6E 022D-F71A-90EF 01C6-1666-B875 3F09-9C35-C4B8 A0B2-AC30-0431 D95D-1D12-987A 9AEE-FACD-3990
思科交换机格式
[root@dameng linuxscript]# sed 's/://g' maclist | sed 's/\(....\)/\1./g;s/.$//' D753.20B3.E3FE 1E91.790D.B1DB 4EB0.1A0D.11D2 BF59.7F40.EF6E 022D.F71A.90EF 01C6.1666.B875 3F09.9C35.C4B8 A0B2.AC30.0431 D95D.1D12.987A 9AEE.FACD.3990