• EVE-NG中国官方合作伙伴!欢迎加入EmulatedLab主群:593920308,EmulatedLab②群:178989902!!!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏EmulatedLab吧!

19.EVE-NG优化非官方支持镜像的接口显示名称

EVE-NG Maosen | 森 3年前 (2017-06-14) 6852次浏览 3个评论 扫描二维码

请在微信公众号中回复“EVE-NG”获取下载链接!

请在微信公众号中回复“Dynamips”获取 Dynamips 下载链接,回复“IOL”获取 IOL 下载链接!

请在微信公众号中回复“QEMU”获取 QEMU 下载链接!

请在微信公众号中回复“Plus”获取H3CHuawei 等非官方支持镜像的下载链接!

请在微信公众号中回复“Tools”获取Tools下载链接!

19.EVE-NG 优化非官方支持镜像的接口显示名称

目前已优化的设备包含:

            H3C vSR

            H3C vFW

            H3C vLB

            HuaweiUSG

            HillStone

以 H3C vSR 举例

原接口名称

19.EVE-NG 优化非官方支持镜像的接口显示名称

终端执行命令

 

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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / \n12).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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 中显示的名称吻合

19.EVE-NG 优化非官方支持镜像的接口显示名称

 

 

 

注意:

老用户直接执行命令即可!

新用户在导入设备时,接口名称就已优化,无需额外执行命令!

 

所有设备相应的执行命令:(每个命令都有细微差别)

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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / \n12).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / \n12).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / \n12).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / 512).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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 <\$this -> 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(‘%02x’, \$this ->tenant).’:’.sprintf(‘%02x’, \$this -> id / 512).’:’.sprintf(‘%02x’, \$this-> id % 512).’:00:’.sprintf(‘%02x’, \$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

 

感谢群友[辽宁]-奥斯丁提供的支持!


如未注明,均为原创,版权归 EmulatedLab 所有!转载请注明出处,否则追究法律责任!
喜欢 (15)
[sms1107]
分享 (0)
Maosen | 森
关于作者:
真正的强者从不畏惧别人比你更强!

您必须 登录 才能发表评论!

(3)个小伙伴在吐槽
  1. hillstone 是空配的,命令行界面要进一个接口敲IP地址,并且敲manage webserver 和manage http才可以用web进入。配置命令格式和思科的差不多
    psppoke2019-04-26 17:16
  2. HillStone telnet能登陆上,但是web不能直接使用,系统的默认配置ip地址192.168.0.1 ,在默认的配置中好像已经不存在了。
    rong2018-05-22 16:08