Ubuntu系统如何安装双网卡及更改网卡名称(eth0改为eth1)

最近,需要在Ubuntu系统上安装一块千兆网卡,使用到了一些网卡的安装、配置及更改操作。

网卡可安装到任意一个PCI插槽,网卡型号D-Link DGE-530T。Ubuntu采用的是8.04 server版本。由于Ubuntu系统带有该网卡的驱动,因此,不必手动安装驱动。安装完成后进入系统,使用lspci查看是否有以下信息

Ethernet controller: Intel Corporation 82562V-2 10/100 Network Connection

Ethernet controller: D-Link System Inc DGE-530T Gigabit Ethernet Adapter

其中,第一行所显示的网卡是系统原有的集成网卡,第二行所显示的网卡是新添加的D-Link网卡。如果仅有一行Ethernet信息,则说明新添加的网卡没有加载,需要手动安装驱动程序。

新网卡添加后,即可对其进行配置。

注意,此时新网卡的名称时eth1,因为eth0被原有的网卡占用。如果想将新网卡设置为eth0,则需要进行以下步骤。

1)ifconfig eth0和ifconfig eth1查看网卡的MAC地址并记录,MAC地址主要用来区分两块网卡;

2)vi /etc/udev/rules.d/70-persistent-net.rules

3)上面的文件内容与下面类似

# This file was automatically generated by the /lib/udev/write_net_rules

# program run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single line.

 

# PCI device 0x8086:0x10c0 (e1000e)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1a:a0:9d:f2:58", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

 

# PCI device 0x1186:0x4b01 (skge)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:26:5a:81:9f:e7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

其中,NAME="eth0"就是网卡的名称,该名称与MAC地址"00:1a:a0:9d:f2:58"对应。只要更改eth0为eth1,就可以将MAC地址为"00:1a:a0:9d:f2:58"的网卡从eth0变成eth1.

4)更改完后重启机器。

如果无法分清百兆网卡和千兆网卡所对应的eth*,可以使用ethtool eth0和ethtool eth1查看。如果ethtool eth0显示的信息类似与下面

Settings for eth0:

Supported ports: [ TP ]

Supported link modes:  10baseT/Half 10baseT/Full

                       100baseT/Half 100baseT/Full

                       1000baseT/Half 1000baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

                       100baseT/Half 100baseT/Full

                       1000baseT/Half 1000baseT/Full

说明eth0是千兆网卡,如果ethtool eth0显示的信息类似与下面

Settings for eth0:

Supported ports: [ TP ]

Supported link modes:  10baseT/Half 10baseT/Full

                       100baseT/Half 100baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

                       100baseT/Half 100baseT/Full

说明eth0是百兆网卡。

对网络进行设置,可以编辑vi /etc/network/interfaces,类似与下

# This file describes the network interfaces available on your system

# and how to activate them. For more information, see interfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

auto eth0   #设置eth0

iface eth0 inet static

   address 192.168.37.76

   netmask 255.255.255.0

   network 192.168.37.0

   broadcast 192.168.37.255

   gateway 192.168.37.254

   dns-nameservers 192.168.37.254

 

#auto eth1   #设置eth1

#iface eth1 inet static

#address xxx

 

#auto eth0:1   #单网卡设置多个IP

#iface eth0:1 inet static

#address 192.168.1.60

#netmask 255.255.255.0

#network x.x.x.x

#broadcast x.x.x.x

#gateway x.x.x.x

设置完后重启网络

/etc/init.d/networking restart

你可能感兴趣的:(linux系统)