localhost ~ # cd /etc/conf.d
建立eth0的配置文件,添加信息如下:
localhost conf.d # cat net.eth0
config_eth0=”192.168.1.21 netmask 255.255.255.0 brd 192.168.1.255″
routes_eth0=”default via 192.168.1.1″
2、建立eth0的启动文件,并设置开机启动
localhost conf.d # cd /etc/init.d/
localhost conf.d # ln -s net.lo net.eth0
localhost conf.d # rc-update add net.eth0 default
3、设备名变更是较新版udev做的事,因为使用了传统命名方式,可以建一空文件
localhost init.d # cd /etc/udev/rules.d/
localhost rules.d # touch 80-net-name-slot.rules
设置以上内容后,重启就可以了
localhost ~ # dmesg | grep eth
[ 2.622345] jme: JMicron JMC2XX ethernet driver version 1.0.8
[ 8.166952] pcnet32: eth0: registered as PCnet/PCI II 79C970A
[ 9.001497] pcnet32 0000:02:00.0 eth0: link up
localhost ~ # ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.21 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::250:56ff:feaf:1a6d prefixlen 64 scopeid 0x20<link>
ether 00:50:56:af:1a:6d txqueuelen 1000 (Ethernet)
RX packets 555 bytes 47970 (46.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 291 bytes 37487 (36.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 18 base 0x2000
补充:如果只使用DHCP客户端自动分配IP,请执行以下操作:
emerge dhcpcd
rc-update add dhcpcd default