Linux IP别名和多网卡绑定
㈠ 网卡高级命令
① mii-tool eth0:查看网卡状态
② ethtool查看网卡设置
ethtool -i eth0:查看网卡的驱动程序
ethtool eth0:查看网卡物理特性
ethtool -S eth0:查看网卡底层状态
㈡ IP别名
一张物理网卡上配置多个IP,实现类似子接口之类的功能,称为IP别名
在linux作DHCP服务器向多网段分配不同IP或者linux作路由器等时可能需要在一个物理接口上配置多个IP地址
⑴ step_1
redhat缺省使用NetworkManager对网卡进行管理,但仅限最基本的功能
若要实现IP别名或者多网卡绑定,需要将此禁用
[root@localhost ~]# service NetworkManager stop 停止 NetworkManager 守护进程: [确定] [root@localhost ~]# chkconfig NetworkManager off [root@localhost ~]# service NetworkManager status NetworkManager is stopped
⑵ step_2
[root@localhost ~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:5E:10:AB inet addr:192.168.1.112 Bcast:255.255.255.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1 RX packets:520 errors:0 dropped:0 overruns:0 frame:0 TX packets:287 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:82430 (80.4 KiB) TX bytes:35734 (34.8 KiB) [root@localhost ~]# ip addr add 192.168.1.200/24 dev eth0 label eth0:0 [root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:5E:10:AB inet addr:192.168.1.112 Bcast:255.255.255.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1 RX packets:700 errors:0 dropped:0 overruns:0 frame:0 TX packets:395 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:105711 (103.2 KiB) TX bytes:48168 (47.0 KiB) eth0:0 Link encap:Ethernet HWaddr 00:0C:29:5E:10:AB inet addr:192.168.1.200 Bcast:0.0.0.0 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1
如果想要永久性添加IP别名,则可以在/etc/sysconfig/network-scripts/下添加别名配置文件:
配置文件名:
ifcfg-eth0:0
内容:
DEVICE=eth0:0
IPADDR=192.168.1.200
PREFIX=24 //子网掩码
ONPARENT=yes //依附关系
㈢ 多网卡绑定