Linux系统双网卡绑定配置教程

Linux系统双网卡绑定配置教程,第1张

系统版本

[root@ ~]# cat /etc/redhat-release

CentOS release 6.8 (Final)

[root@ ~]# uname -r

2.6.32-642.6.1.el6.x86_64

网卡说明

eth0   192.168.1.8(服务器外网卡)

eth1   服务器网卡(内网)

eth2   服务器网卡(内网)

[root@ ~]# /etc/init.d/iptables stop

[root@ ~]#  chkconfig iptables off

关闭selinux

[root@ ~]#setenforce 0

[root@ ~]#sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config

禁用NetworkManager

[root@ ~]# /etc/init.d/NetworkManager stop

Stopping NetworkManager daemon:           [  OK  ]

[root@ ~]# chkconfig NetworkManager off

[root@ ~]# /etc/init.d/network restart

双网卡绑定配置过程

[root@ ~]# cd /etc/sysconfig/network-scripts/

编辑eth1网卡

[root@ network-scripts]# cat >ifcfg-eth1 <>DEVICE=eth1

>ONBOOT=yes

>BOOTPROTO=none

>USERCTL=no

>MASTER=bind0

>EOF

编辑eth2网卡

[root@ network-scripts]# cat >ifcfg-eth2

ONBOOT=yes

BOOTPROTO=none

USERCTL=no

MASTER=bind0

EOF

编辑bind0网卡

[root@ network-scripts]# cat >ifcfg-bind0 <>DEVICE=bind0

>TYPE=Ethernet

>ONBOOT=yes

>BOOTPROTO=none

>IPADDR=10.0.0.8

>NETMASK=255.255.255.0

>GATEWAY=10.0.0.254

>IPV6INIT=no

>USERCTL=no

>EOF

配置bond参数

[root@ network-scripts]# cat >/etc/modprobe.conf <>alias bind0 bonding

>options bind0 miimon=100 mode=6

>EOF

加入开机自启动(/etc/rc.local)

[root@ network-scripts]# cat >>/etc/rc.local <>ifenslave bind0 eth1 eth2

>EOF

重启网络服务

[root@LVS-2 network-scripts]# service network restart

Shutting down interface eth0:                              [  OK  ]

Shutting down interface eth1:                              [  OK  ]

Shutting down interface eth2:                              [  OK  ]

Shutting down loopback interface:                       [  OK  ]

Bringing up loopback interface:                            [  OK  ]

Bringing up interface bind0:  WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.

WARNING: Deprecated config file /etc/modprobe.conf, all config files belong into /etc/modprobe.d/.

Determining if ip address 10.0.0.8 is already in use for device bind0..[  OK  ]

Bringing up interface eth0:  Determining if ip address 192.168.1.8 is already in use for device eth0...                                                     [  OK  ]

Bringing up interface eth1:  RTNETLINK answers: File exists         [  OK  ]

Bringing up interface eth2:  RTNETLINK answers: File exists          [  OK  ]

配置使绑定立即生效

[root@LVS-2 network-scripts]# ifenslave bind0 eth1 eth2

测试联通

[root@LVS-2 network-scripts]# ping 10.0.0.8

PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.

64 bytes from 10.0.0.8: icmp_seq=1 ttl=64 time=0.089 ms

64 bytes from 10.0.0.8: icmp_seq=2 ttl=64 time=0.046 ms

^C

--- 10.0.0.8 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1921ms

rtt min/avg/max/mdev = 0.046/0.067/0.089/0.023 ms

此时会发现系统多一个网卡

[root@LVS-2 network-scripts]# ifconfig bind0

bind0

Link encap:Ethernet  HWaddr 00:0C:29:CC:9B:5

inet addr:10.0.0.8  Bcast:10.0.0.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fecc:9b55/64 Scope:LinkUP BROADCAST RUNNING MASTER MULTICAST  MTU:1500 Metric:1

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

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

collisions:0 txqueuelen:0

RX bytes:11826 (11.5 KiB)  TX bytes:258 (258.0 b)

linux下配置网络步骤方法:

配置动态IP

1、在终端命令窗口中输入setup,就会d出如下窗口。

[root@wgods ~]# setup

2、选择Network Configuration,点击enter进入下面界面。

3、选择Edit Devices选项进入下面界面

4、点击enter,选项进入下面界面,按Tab键在选项间切换,选择Use DHCP后,按下空格键,就会出现[*],然后点击OK键。注意:有时候在Name或Device选项不小心,让eth0多了空格,就会造成配置出问题,此时要检查一下/etc/sysconfig/network-scripts/ifcfg-eth0配置文件,才能发现问题。否则这种细节问题会纠结很久的。

拓展资料

1、网卡上面装有处理器和存储器(包括RAM和ROM)。网卡和局域网之间的通信是通过电缆或双绞线以串行传输方式进行的。而网卡和计算机之间的通信则是通过计算机主板上的I/O总线以并行传输方式进行。因此,网卡的一个重要功能就是要进行串行/并行转换。由于网络上的数据率和计算机总线上的数据率并不相同,因此在网卡中必须装有对数据进行缓存的存储芯片。

2、在安装网卡时必须将管理网卡的设备驱动程序安装在计算机的 *** 作系统中。这个驱动程序以后就会告诉网卡,应当从存储器的什么位置上将局域网传送过来的数据块存储下来。网卡还要能够实现以太网协议。

3、网卡并不是独立的自治单元,因为网卡本身不带电源而是必须使用所插入的计算机的电源,并受该计算机的控制。因此网卡可看成为一个半自治的单元。当网卡收到一个有差错的帧时,它就将这个帧丢弃而不必通知它所插入的计算机。当网卡收到一个正确的帧时,它就使用中断来通知该计算机并交付给协议栈中的网络层。当计算机要发送一个IP数据包时,它就由协议栈向下交给网卡组装成帧后发送到局域网。

4、随着集成度的不断提高,网卡上的芯片的个数不断的减少,虽然各个厂家生产的网卡种类繁多,但其功能大同小异。

参考资料:百度百科:网卡


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8585729.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-18
下一篇2023-04-18

发表评论

登录后才能评论

评论列表(0条)

    保存