2009年4月16日木曜日

VMware Clone Debian 後 Networking 及 Hostname 問題

VMware Clone Debian 後 Networking 及 Hostname 問題
當 Debian 從現有 VMware Machine Clone 出來後,Network Card 的 MAC Address 會改變,而 Debian 因已經記錄了上一次 VMware Machine 的 MAC Address,所以會出現 eth0 不能啟動問題。加上 hostname 都需要更改。本文會寫出改 MAC Address 及 hostname 的方法。

方法如下:

1. 用 root 身分登入
$su

2. 修改 /etc/udev/rules.d/z25_persistent-net.rules
#vim /etc/udev/rules.d/z25_persistent-net.rules

3. 打開 z25_persistent-net.rules 後,你會看見如以下的字句。請把所有類似的字句刪除。刪除後 :wq 儲存及關閉 vim。
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0c:29:8d:0d:c1", NAME="eth0"

4. 更新 hostname:打開 /etc/hostname,及更改 host 名。改好後 :wq 儲存及關閉 vim。
#vim /etc/hostname

5. 打開 /etc/hosts,及更改 host 名。改好後 :wq 儲存及關閉 vim。
#vim /etc/hosts

從:
127.0.0.1 debian.localdomain debain

改為
127.0.0.1 webserver.localdomain webserver

6. 重新啟動電腦
# reboot

重新啟動後﹐你會發現 /etc/udev/rules.d/z25_persistent-net.rules 內的 MAC 地址已經更新。

7.你可以在 /etc/network/interfaces 內更新 IP 設定。

网络接口参数配置文件,下面是一个配置示例,它在一个网络接口中配置了两个静态IP地址:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
# gateway 192.168.1.1
# name 以太网局域网网卡

auto eth0:0
iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
下面是一个从DHCP服务器自动获得IP地址的示例:

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet dhcp

0 件のコメント: