2014年10月27日 星期一

Ubuntu 14.04 rename network interface

本來一直以為在Ubuntu下,網卡大多都會以eth*來做為命名,但後來我發現原來不是,所以就想說把系統上原本設定的網卡名稱給重新命名

首先,先找出目前有哪幾張網卡,並將其網卡的mac address找出來

ifconfig -a | grep -i hwaddr

找到後,編輯 /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="網卡的mac address", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

 網卡的mac:已經透過 ifconfig -a | grep -i hwaddr 找出來,就把它填寫進去就行了。

 eth*:也是透過ifconfig -a 可以找到,或是到dmesg找也行。

eth0:變更成你自已想要的網卡名稱。


接下來就可以用 ifconfig eth0 up 把網卡叫起來了,設定網卡在  /etc/network/interface 下可以設定自已想要的static ip,設定好之後就可以重開服務了。


/etc/init.d/networking restart



service network-interface restart INTERFACE=eth0

第二個方法是參考自 /etc/init/network-interface.conf ,這個方法可以不開機就重開網路介面的方式。


References:
http://www.cyberciti.biz/faq/howto-linux-rename-ethernet-devices-named-using-udev/