linux设置双网卡band,centos设置双网卡绑定band0

本文详细介绍了如何在Linux系统中设置双网卡负载均衡,通过bonding技术将eth0和eth1两块网卡绑定为bond0虚拟网卡,配置IP地址、网络参数,并启用负载均衡模式,确保网络高可用性和带宽优化。
摘要由CSDN通过智能技术生成

1、执行setup命令-->网络配置-->本例中四块网卡。

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

2、ifconfig列出四块网卡。

3、我们的目标,绑定eth0和eth1两块网卡作为公网网卡,ip设置为192.168.0.51

4、首先备份两块网卡的配置文件

Mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/bak_network-scripts/ifcfg-eth0_bak

Mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/bak_network-scripts/ifcfg-eth1_bak

5、重新创建ifcfg-eth0网卡配置文件

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

USERCTL=no

ONBOOT=yes

SLAVE=yes

MASTER=bond0

BOOTPROTO=none

6、重建eth1网卡配置文件

vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

USERCTL=no

ONBOOT=yes

SLAVE=yes

MASTER=bond0

BOOTPROTO=none

7、创建bond0虚拟网卡配置文件

Vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0

IPADDR=192.168.0.51

NETMASK=255.255.255.0

USERCTL=no

BOOTPROTO=none

ONBOOT=yes

GATEWAY=192.168.0.1

IPV6INIT=no

TYPE=Ethernet

#DNS1=192.168.0.1

8、修改配置文件/etc/modprobe.d/dist.conf

vi dist.conf

最后新增如下两行:

alias bond0 bonding

options bond0 miimon=100 mode=0

mode=0表示做负载均衡

9、加载bond0模块

[root@rac1 modprobe.d]# modprobe bonding

[root@rac1 modprobe.d]# lsmod |grep bond

bonding 127331 0

8021q 25317 1 bonding

ipv6 321422 30 bonding,ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6

10、重启网络服务

service network stop

11、最好也重启下sshd服务

service sshd restart

12、查看bond0状态:

[root@rac1 network-scripts]# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: load balancing (round-robin)

MII Status: up

MII Polling Interval (ms): 0

Up Delay (ms): 0

Down Delay (ms): 0

Slave Interface: eth0

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 08:00:27:fc:7e:5b

Slave queue ID: 0

Slave Interface: eth1

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 08:00:27:6f:e3:9d

Slave queue ID: 0

[root@rac1 network-scripts]#

13、查看ifconfig

[root@rac1 network-scripts]# ifconfig

bond0 Link encap:Ethernet HWaddr 08:00:27:FC:7E:5B

inet addr:192.168.0.51 Bcast:192.168.0.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fefc:7e5b/64 Scope:Link

UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1

RX packets:4135 errors:0 dropped:0 overruns:0 frame:0

TX packets:2025 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:375692 (366.8 KiB) TX bytes:261792 (255.6 KiB)

eth0 Link encap:Ethernet HWaddr 08:00:27:FC:7E:5B

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:3394 errors:0 dropped:0 overruns:0 frame:0

TX packets:1640 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:304735 (297.5 KiB) TX bytes:219122 (213.9 KiB)

eth1 Link encap:Ethernet HWaddr 08:00:27:FC:7E:5B

UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1

RX packets:742 errors:0 dropped:0 overruns:0 frame:0

TX packets:387 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:71017 (69.3 KiB) TX bytes:43378 (42.3 KiB)

eth2 Link encap:Ethernet HWaddr 08:00:27:18:29:48

inet addr:192.168.0.7 Bcast:192.168.0.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fe18:2948/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:862 errors:0 dropped:0 overruns:0 frame:0

TX packets:113 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:77480 (75.6 KiB) TX bytes:12978 (12.6 KiB)

eth3 Link encap:Ethernet HWaddr 08:00:27:59:1E:79

inet addr:192.168.0.99 Bcast:192.168.0.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fe59:1e79/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:768 errors:0 dropped:0 overruns:0 frame:0

TX packets:42 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:73511 (71.7 KiB) TX bytes:2732 (2.6 KiB)

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:8 errors:0 dropped:0 overruns:0 frame:0

TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:728 (728.0 b) TX bytes:728 (728.0 b)

[root@rac1 network-scripts]#

注意eth0和eth1是不应该有ip显示的。

14、ok

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值