歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux雙網卡綁定一個IP的實現

Linux雙網卡綁定一個IP的實現

日期:2017/2/28 17:10:08   编辑:Linux教程

Linux雙網卡綁定一個IP實現教程

由於客戶機比較多我們可以做到二塊網卡同時工作。開始做了。

rh el 5測試通過。。

網卡1為eth0 網卡2為eth1 (這個大家都知道)

1.先修改eth0 和eht1這2個網卡配置文件.目錄在(/etc/sysconfig/network-scripts/)如下:

DEVICE=eth0

ONBOOT=yes

MASTER=bond0

BOOTPROTO=none (這個最好不要為DHCP 一點啟動慢,二點你網吧有DHCP了,想想!呵呵)

2. eth1 也是同樣的修改.如下:

DEVICE=eth1

ONBOOT=yes

MASTER=bond0

BOOTPROTO=none (這個最好不要為DHCP 一點啟動慢,二點你網吧有DHCP了,想想!呵呵)

3.新建一個虛擬網卡bond0,我們可以復制eth0的,復制後要修改內容.

復制 (cp /etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-bond0)修改內容為如下:

DEVICE=bond0

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.0.227

NETMASK=255.255.255.0

BROADCAST=192.168.0.255

TYPE=Ethernet

4.修改/etc/modprobe.conf,添加內容如下:

alias bond0 bonding

options bond0 miimon=100 mode=1

注意:mode可以為0, 1, 0為負載均衡,1為失效保護, 我們只用到0

關於:modprobe.conf文件在AS版本裡面有,Linux9.0的是這個modules.conf文件

5:修改/etc/rc.d/rc.local,添加內容如下:

ifenslave bond0 eth0 eth1

route add -net 192.168.0.255 netmask 255.255.255.0 bond0

完成。。。。。。。。。。。

查看:

[root@LMsev ~]# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.0.3 (March 23, 2006)

Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eth0

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eth0

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:ea:73:0f

Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:0c:29:ea:73:19

Copyright © Linux教程網 All Rights Reserved