签到成功

知道了

CNDBA社区CNDBA社区

linux6--linux7 双网卡管理

2016-12-08 11:56 2932 0 原创
作者: Anshen

若水三千,我只饮一瓢!在众多操作系统中,我独对Linux 情有独钟。

但是在Linux7 以后不但用systemctl来管理服务了,进程界别也是systemd.就连大家熟悉的eth0-eth1都变成-》》eno16………………。

鉴于强迫症。我必须把它修改回来。因为我在这里采用的oracle virtual box虚拟机。所以网卡名称上会有不一样。但是,修改方式是一样的。

 

http://www.cndba.cn/redhat/article/1622

                                             

 

接下来修改配置文件

rhgb quiet 后面添加如下内容:net.ifnames=0 biosdevname=0

修改完毕后执行:

[root@db1 sysconfig]# grub2-mkconfig -o /boot/grub2/grub.cfg

http://www.cndba.cn/redhat/article/1622

Reboot重启服务器。即可

 

Linux6做双网卡绑定

 

Redhat-Linux6 双网卡绑定。

首先强调一点,更改eth0eth1配置时一定要注释掉其相应的MAC地址.


Eth1       绑定为:bond0

           

首先进入到这个目录编辑eth0  eth1配置文件。

 

[root@db network-scripts]# cat ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

MASTER=bond0

SLAVE=yes

BOOTPROTO=none

USERCTL=no

 

 

 

[root@db network-scripts]# cat ifcfg-eth1

DEVICE=eth1

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=no

MASTER=bond0

SLAVE=yes

BOOTPROTO=none

USERCTL=no

 

 

接下来编辑 Vim ifcfg-bond0

 

[root@db network-scripts]# vim ifcfg-bond0

DEVICE=bond0

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.0.230

NETMASK=255.255.255.0

GATEWAY=192.168.0.254

DNS1=10.10.10.1

DNS2=20.20.20.2

USERCTL=no

 

红色标记可以根据情况添加。不多做阐述。

 

 

接下来修改

[root@db network-scripts]# cd /etc/modprobe.d/

[root@db modprobe.d]# ls

anaconda.conf   dist-alsa.conf  dist-oss.conf

blacklist.conf  dist.conf       openfwwf.conf

[root@db modprobe.d]# pwd

/etc/modprobe.d

[root@db modprobe.d]#

编辑这个文件

Vim dist.conf

alias bond0 bonding

options bond0 miimon=100 mode=0http://www.cndba.cn/redhat/article/1622

文件末尾加上这两句话。
#选项 millmon 是指定隔多长时间来进行链路监测,单位是ms
#
选项 mode 是表示绑定口的工作模式,有0-77种模式,常用的有01模式,mode=0表示"round-robin"策略,两张卡同时工作在负载均衡状态。mode=1表示"active-backup"策略,两张卡一用一备的备份状态

 

是要备份还是要轮询(负载均衡),可以根据实际工作中需求来做相应配置。

 

最后修改  /etc/rc.local,负责在系统启动时将虚拟网卡和两张物理网卡相绑定。

 http://www.cndba.cn/redhat/article/1622

重启网卡生效。Service network restart.

 

最后值得注意的是:eth0  eth1 他们获得MAC地址是一模一样的哦!

[root@db ~]# ifconfig

bond0     Link encap:Ethernet  HWaddr 08:00:27:1E:06:6B 

          inet addr:192.168.0.230  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::a00:27ff:fe1e:66b/64 Scope:Link

          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:0

          RX bytes:393887 (384.6 KiB)  TX bytes:271941 (265.5 KiB)

 http://www.cndba.cn/redhat/article/1622

eth0      Link encap:Ethernet  HWaddr 08:00:27:1E:06:6B 

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000http://www.cndba.cn/redhat/article/1622

          RX bytes:380078 (371.1 KiB)  TX bytes:135250 (132.0 KiB)

 

eth1      Link encap:Ethernet  HWaddr 08:00:27:1E:06:6B 

          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000

          RX bytes:13809 (13.4 KiB)  TX bytes:136691 (133.4 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:480 (480.0 b)  TX bytes:480 (480.0 b)

 http://www.cndba.cn/redhat/article/1622

但是需要注意 networkmanager服务关闭并设置为开机不启动 以防止干扰相关的操作。

[root@db ~]# service NetworkManager stop

Stopping NetworkManager daemon: [FAILED]

[root@db ~]# chkconfig NetworkManager off

[root@db ~]#

 

 

Linux 7 双网卡绑定

 

http://www.cndba.cn/redhat/article/1622

查看操作系统版本。

在这里我已经把Linux网卡名字有eno16…………修改为:eth0 eth1 eth2……

 

Linux7 的双网卡绑定首先要yum –y install teamd

安装这个软件包。

[root@db4 home]# mount /dev/cdrom /mnt

mount: /dev/sr0 is write-protected, mounting read-only

[root@db4 home]# df

Filesystem     1K-blocks     Used Available Use% Mounted on

/dev/sda2       20469760 15969132   4500628  79% /

devtmpfs         1413700        0   1413700   0% /dev

tmpfs            1421992       80   1421912   1% /dev/shm

tmpfs            1421992     8968   1413024   1% /run

tmpfs            1421992        0   1421992   0% /sys/fs/cgroup

/dev/sda5       35822500  8084428  27738072  23% /u01

/dev/sda1        1020588   124772    895816  13% /boot

/dev/sr0         4138442  4138442         0 100% /mnt

光盘挂在上来。

配置好yum仓库。

 

[root@db4 home]# yum -y install teamd

 

http://www.cndba.cn/redhat/article/1622

我这里已经安装过的。

 

 

 

[root@db4 network-scripts]# more ifcfg-eth1

DEVICE=eth1

DEVICETYPE=TeamPort

ONBOOT=yes

TEAM_MASTER=team0

TEAM_PORT_CONFIG='{"prio": 100}'

 

[root@db4 network-scripts]# more ifcfg-eth2

DEVICE=eth2

DEVICETYPE=TeamPort

ONBOOT=yes

TEAM_MASTER=team0

TEAM_PORT_CONFIG='{"prio": 200}'

[root@db4 network-scripts]# more ifcfg-team0

DEVICE=team0

DEVICETYPE=Team

ONBOOT=yes

BOOTPROTO=none

IPADDR=192.168.0.200

PREFIX=24

TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

[root@db4 network-scripts]#

 


 

最终我们检验一下。看看两块网卡获得MAC 地址是否一致。

http://www.cndba.cn/redhat/article/1622

 

GOOD 现在你已经完成了!  Redhat Linux6 redhatLinux7上双网卡绑定的工作了。

 

(其实我想说的是:虽然redhatLinux7 采用teaming 方式绑定网卡,但是 他并没有抛弃bond方式绑定网卡,2种方式,任选其一。 为了学习新知识,还是采用teaming 方式最好。)


版权声明:本文为博主原创文章,未经博主允许不得转载。

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Anshen

Anshen

关注

成功不是将来才有的,而是从决定去做的那一刻起,持续累积而成。

  • 69
    原创
  • 0
    翻译
  • 5
    转载
  • 8
    评论
  • 访问:291875次
  • 积分:326
  • 等级:中级会员
  • 排名:第13名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ