跳到主要內容

解決在Ubuntu/Debian底下因更換網路卡或將硬碟安裝在另一台伺服器之後找不到eth0/網路的問題

Ubuntu Desktop / Ubuntu Server / Kubuntu與Debian會紀錄網路卡的MAC Address來判斷目前所用的網卡是否與紀錄一致, 倘若不同, 就會自動新增一筆紀錄. 所以就算更換新的網卡(同樣道理, 在A 電腦的VirtualOS 的網卡與B電腦的VirtualOS 的網卡Mac Address 不同), 舊網卡的資料還是一樣會被判定成eth0, 而其他新增的網卡會依照eth1,eth2...一直自動新增下去.

解決的辦法:

sudo vi /etc/udev/rules.d/70-persistent-net.rules

你會看到類似以下的參數設定...


# PCI device 0x10de:0x00df (forcedeth)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10de:0x00df (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="55:44:33:22:11:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


只保留最底下的參數 (# PCI device 0x10de:0x00df (forcedeth) 開始), 其餘的通通刪除, 並且將NAME="eth1" 更改成 NAME="eth0"


範例:
# PCI device 0x10de:0x00df (forcedeth)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


# PCI device 0x10de:0x00df (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="55:44:33:22:11:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


更改之後, /etc/udev/rules.d/persistent-net.rules 內的參數如下:

# PCI device 0x10de:0x00df (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="55:44:33:22:11:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"


修改完畢並且儲存之後重新啟動伺服器 (sudo shutdown -r now)就行了.



注: 這方法適用於所有使用Ubuntu/Debian 的伺服器/電腦.  不管是否用Virtualbox, 都可以用.  比如VMWare 或者安裝在真正的硬碟而非虛擬OS.


參考資料: http://nabeko-notebook.blogspot.com/2009/04/eth0debianubuntu.html

留言

這個網誌中的熱門文章

解決Apache 2.2, 關於HTTPS 之下使用PROXY 面對的 proxy server received an invalid response from an upstream server 以及 proxy: pass request body failed 的問題

修改以下 (proxy 以及 從proxy 接收的server): httpd.conf: ----------- 在 Include conf.d/*.conf 的前面加入以下: LimitRequestBody 2147483647  #2Gb Timeout 24000 ProxyTimeout 24000 ProxyBadHeader Ignore ssl.conf ---------- 在各個virtualhost 裡加入以下:     SSLEngine on     SSLProxyEngine on     SSLProxyVerify none     SSLProxyCheckPeerCN off     #SSLProxyCheckPeerName off     SSLProxyProtocol +SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2 以下這個只在proxy server 裡的virtualhost 設定     ProxyPass / https://REMOTE_HOST:443/ retry=1 acquire=3000 timeout=3600 Keepalive=On 

解決CentOS 8 的 failed to set locale defaulting to c.utf-8 的問題

這原因是沒有安裝好支援的語言與字型, 特別是UTF8 並沒有被安裝到 因此使用以下指令確認 localedef -i en_US -f UTF-8 en_US.UTF-8 假如出現 "[error] character map file `UTF-8' not found: No such file or directory" 或者 [error] default character map file 'ANSI_X3.4-1968' not found : No such file or directory 那就安裝UTF8 吧 yum whatprovides "*/UTF-8.gz" 如果找到的話 "UTF-8.gz" 的話 yum install "*/UTF-8.gz" -y 再執行一次: localedef -i en_US -f UTF-8 en_US.UTF-8