目前已优化的设备包含:
H3C
vSR
H3C
vFW
H3C
vLB
HuaweiUSG
HillStone
以 H3C vSR 举例
原接口名称
终端执行命令
root@eve-ng:~#cp/opt/unetlab/html/includes/__node.php{,.`date
+%s`}&&sed -i “/case’a10′:/i\\\t\t\t\t\tcase
‘vsr’:\n\t\t\t\t\t\tfor (\$i = 0; \$i < \$this-> ethernet;
\$i++) {\n\t\t\t\t\t\t\t\$n =
‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))
{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old
one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =
\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttry
{\n\t\t\t\t\t\t\t\t\t\$this -> ethernets[\$i] =
newInterfc(Array(‘name’ => \$n, ‘type’ =>
‘ethernet’),\$i);\n\t\t\t\t\t\t\t\t} catch (Exception
\$e){\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this
->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
root@eve-ng:~#
更改后的接口名称与 OS 中显示的名称吻合
注意:
老用户直接执行命令即可!
新用户在导入设备时,接口名称就已优化,无需额外执行命令!
所有设备相应的执行命令:(每个命令都有细微差别)
1、H3C vSR:
cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed
-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vsr’:\n\t\t\t\t\t\tfor (\$i = 0;
\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =
‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))
{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old
one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =
\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else
{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->
ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>
‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)
{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this
->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
2、H3C vFW:
cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed
-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vfw’:\n\t\t\t\t\t\tfor (\$i = 0;
\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =
‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))
{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old
one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =
\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else
{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->
ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>
‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)
{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this
->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
3、H3C vLB:
cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed
-i “/case’a10′:/i\\\t\t\t\t\tcase ‘vlb’:\n\t\t\t\t\t\tfor (\$i = 0;
\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\t\$n =
‘Gi’.(\$i+1).’/0′; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))
{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old
one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =
\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else
{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->
ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>
‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)
{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
\n12).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this
->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
4、Huawei USG:
cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed
-i “/case’a10′:/i\\\t\t\t\t\tcase ‘usg’:\n\t\t\t\t\t\tfor (\$i = 0;
\$i < \$this-> ethernet; \$i++) {\n\t\t\t\t\t\t\tif (\$i==0)
{\n\t\t\t\t\t\t\t\t\$n
=’Gi0/’.\$i.’/0′; //Interface name\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\$n
=’Gi1/0/’.(\$i-1); //Interface name\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif
(isset(\$old_ethernets[\$i])){\n\t\t\t\t\t\t\t\t// Previous
interface found, copy from oldone\n\t\t\t\t\t\t\t\t\$this ->
ethernets[\$i] =\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else
{\n\t\t\t\t\t\t\t\ttry{\n\t\t\t\t\t\t\t\t\t\$this ->
ethernets[\$i] = new Interfc(Array(‘name’=> \$n, ‘type’ =>
‘ethernet’), \$i);\n\t\t\t\t\t\t\t\t} catch (Exception\$e)
{\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
512).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this ->
id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
5、HillStone:
cp/opt/unetlab/html/includes/__node.php{,.`date +%s`}&&sed
-i “/case’a10′:/i\\\t\t\t\t\tcase ‘hillstone’:\n\t\t\t\t\t\tfor
(\$i = 0; \$i ethernet; \$i++)
{\n\t\t\t\t\t\t\t\$n =
‘ethernet0/’.\$i; // Interfacename\n\t\t\t\t\t\t\tif (isset(\$old_ethernets[\$i]))
{\n\t\t\t\t\t\t\t\t//Previous interface found, copy from old
one\n\t\t\t\t\t\t\t\t\$this ->ethernets[\$i] =
\$old_ethernets[\$i];\n\t\t\t\t\t\t\t} else{\n\t\t\t\t\t\t\t\ttry
{\n\t\t\t\t\t\t\t\t\t\$this -> ethernets[\$i] =
newInterfc(Array(‘name’ => \$n, ‘type’ =>
‘ethernet’),\$i);\n\t\t\t\t\t\t\t\t} catch (Exception
\$e){\n\t\t\t\t\t\t\t\t\terror_log(date(‘M d H:i:s
‘).’ERROR:’.\$GLOBALS[‘messages’][40020]);\n\t\t\t\t\t\t\t\t\terror_log(date(‘M
d H:i:s’).(string)
\$e);\n\t\t\t\t\t\t\t\t\treturn40020;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t//
Setting CMD flags(virtual device and map to TAP
device)\n\t\t\t\t\t\t\t\$this -> flags_eth .=’ -device
%NICDRIVER%,netdev=net’.\$i.’,mac=50:’.sprintf(‘x’, \$this
->tenant).’:’.sprintf(‘x’, \$this -> id /
512).’:’.sprintf(‘x’, \$this-> id % 512).’:00:’.sprintf(‘x’,
\$i);\n\t\t\t\t\t\t\t\$this ->flags_eth .= ‘ -netdev
tap,id=net’.\$i.’,ifname=vunl’.\$this ->tenant.’_’.\$this
->id.’_’.\$i.’,script=no’;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n”/opt/unetlab/html/includes/__node.php
http://www.emulatedlab.com/archives/578