首先,確認 kernel 認到多少張網路卡:
root@ubuntu:~# dmesg | grep eth以上輸出,很清楚看到系統抓的兩張網路卡,eth0 & eth1。有些時候,你會看到 "eth0 is renamed to eth1" 之類的訊息。這時候,你用 ifconfig 去看時,會發現網路界面的名稱跟系統抓到的好像不一致。遇到這種情況,請檢查 /etc/udev/rules.d/70-persistent-net.rules:
[ 1.678186] i2c-core: driver [aat2870] using legacy suspend method
[ 1.678186] i2c-core: driver [aat2870] using legacy resume method
[ 2.718021] via-rhine 0000:01:06.0: eth0: VIA Rhine II at 0xfebffc00, 00:11:22:ab:cd:ed, IRQ 19
[ 2.718735] via-rhine 0000:01:06.0: eth0: MII PHY found at address 8, status 0x782d advertising 01e1 Link cde1
[ 2.726899] forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
[ 2.727153] forcedeth 0000:00:0f.0: PCI INT A -> Link[LMAC] -> GSI 20 (level, low) -> IRQ 20
[ 2.727160] forcedeth 0000:00:0f.0: setting latency timer to 64
[ 3.253390] forcedeth 0000:00:0f.0: ifname eth1, PHY OUI 0x732 @ 1, addr 00:33:44:ab:cd:ed
[ 3.253394] forcedeth 0000:00:0f.0: highdma pwrctl mgmt gbit lnktim msi desc-v3
# PCI device 0x1106:/sys/devices/pci0000:00/0000:00:0a.0/0000:01:06.0 (via-rhine)也就是說,網路界面的名稱可被 udev 重新定義。確認網路界面之後 (確認沒有的網路卡,可以直接刪除),就可以設定各個界面的網路型態:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:ab:cd:ef", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10de:/sys/devices/pci0000:00/0000:00:0f.0 (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:33:44:ab:cd:ef", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
root@ubuntu:~# cat /etc/network/interfaces以上範例,eth0 會自動取得 IP,eth1 則自行指定 IP 位址。
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
沒有留言:
張貼留言