Linux随机生成MAC地址

1.使用$RANDOM和md5sum
    #echo $RANDOM | md5sum | sed 's/../&:/g' | cut -c1-17
2.使用openssl工具hex
    [cqs@centos702 ~]$ openssl rand -hex 6 |sed 's/../&:/g;s/:$//'
    9f:13:48:c1:f2:8d
3.使用perl命令
    [cqs@centos702 ~]$ perl -e 'print join(":",map{sprintf "%0.2x",rand(256)}(1..6)), "\n"'
    38:7c:62:a3:9f:a0

猜你喜欢

转载自blog.51cto.com/1929297/2417454