19.EVE-NG優化非官方支持鏡像的接口顯示名稱
文章列表(關註微信公眾號EmulatedLab,及時獲取文章以及下載鏈接)
1、EVE-NG介紹(EVE-NG最好用的模擬器,仿真環境時代來臨!)
2、EVE-NG安裝過程介紹
3、EVE-NG導入Dynamips和IOL
4、EVE-NG導入QEMU鏡像
5、EVE-NG關聯SecureCRT,VNC,Wireshark
6、EVE-NG網卡橋接,帶您走進更高級的實驗
7、EVE-NG硬盤擴容,存儲海量鏡像
8、EVE-NG定制個人鏡像,腳本快速導入
9、EVE-NG容納H3C、Huawei,吞並GNS3
10、EVE-NG鏡像來啦!打造國內最大的EVE交流圈
11、EVE-NG鏡像再次來襲,無所不能!
12、EVE-NG鏡像增持,走上神壇!
13、EVE-NG內存不夠?教您擴大虛擬內存!
14、EVE-NG更新方便,不費勁兒!
15、EVE-NG小眾鏡像,助力嘗鮮!
16、EVE-NG體驗Seafile,拋棄10K/s網盤
17、EVE-NG增添監控服務器鏡像,再上新高度!
18、EVE-NG變身Learning Centre版本及重置Web用戶密碼
19、EVE-NG優化非官方支持鏡像的接口顯示名稱
20、EVE-NG華麗登場Openstack鏡像,體驗私有雲!
點擊查看配套視頻教程!
目前已優化的設備包含:
H3C vSR
H3C vFW
H3C vLB
HuaweiUSG
HillStone
以H3C vSR舉例
原接口名稱
終端執行命令
[email protected]:~# 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
[email protected]:~#
更改後的接口名稱與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(‘%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
感謝群友[遼寧]-奧斯丁提供的腳本!
本篇於2017-06-14在微信公眾號EmulatedLab上發表
Maosen | 森
本文出自 “情系の烏托邦” 博客,請務必保留此出處http://sms1107.blog.51cto.com/2795843/1939677
19.EVE-NG優化非官方支持鏡像的接口顯示名稱