Linux network IP and bond implement multiple network cards using the same IP

Source: Internet
Author: User

One NIC can choose different IP according to the network environment

Sometimes we encounter a situation where, when participating in a company project, the network environment does not have a DHCP service, the IP configuration must be specified manually, and when we go home from work, we must change the IP configuration in order to properly surf the internet. In fact, both Windows and Linux support the configuration of the backup IP, which enables a manually configured backup IP when the master configuration is unable to obtain IP through DHCP. It is worth mentioning that the standby configuration is used only when the primary IP configuration uses DHCP and the alternate configuration must be specified manually.

This configuration is very simple, just create a/etc/sysconf/network-scripts/ifcfg-eth0: #即可, #为任意数字

The contents are:

device=eth0:#

Ipaddr=ip

Prefix=mask

Dns1=dns

...

Restart the network to take effect

650) this.width=650; "style=" width:400px;height:162px; "src=" http://s5.51cto.com/wyfs02/M01/86/C9/ Wkiom1fkjuls0kfyaacuhqfe4gq075.png "title=" eth0100.png "border=" 0 "hspace=" 0 "vspace=" 0 "width=" + "height=" 162 "alt = "Wkiom1fkjuls0kfyaacuhqfe4gq075.png"/>

Second, the use of bond to achieve multi-NIC using the same IP, only for CENTOS6

is to bind multiple network cards to the same IP address to provide services externally, can achieve high availability or load balancing. Of course, it is not possible to set the same IP address directly for two NICs. Through the bonding, the virtual one network card provides the connection externally, the physical network card is modified to the same MAC address.

There are 7 levels of bond. Here take Mode0,mode1,mode2 as an example

MODE0:
Rotation (round-robin) strategy: Send packets above and below each slave interface in a sequential order. This mode provides load balancing and fault tolerance capabilities

Mode1:

Active-Backup (Master) policy: In the binding, only one slave is activated. Other slave are activated when and only if the active slave interface fails. To prevent the switch from confusing, the bound MAC address is visible on only one external port

Mode2:

Broadcast strategy: All messages are transmitted on all slave interfaces. This mode provides fault-tolerant capability.

Create a configuration file for a bonding device

[Email protected] ~]# cat/etc/sysconfig/network-scripts/ifcfg-bond0 device=bond0ipaddr=10.1.70.233prefix= 16bootproto=nonebonding_opts= "Miimon=100 mode=0"
[[email protected] ~]# cat /etc/sysconfig/ Network-scripts/ifcfg-eth0device=eth0#type=ethernet#uuid=5ac4135c-6d2f-43ca-a086-644149193ebb#onboot=yes#nm_ Controlled=yes#bootproto=none#hwaddr=00:0c:29:00:90:1a#ipaddr=10.1.70.101#prefix=16#gateway=10.1.0.1#defroute= No#ipv4_failure_fatal=yes#ipv6init=no#name= "System eth0" master=bond0slave=yes[[email protected]  ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1device=eth1#type=ethernet#uuid= 889cd85b-86bd-4acb-bc4b-6c525f60224c#onboot=yes#nm_controlled=yes#bootproto=dhcp#hwaddr=00:0c:29:00:90:24# Defroute=yes#peerdns=yes#peerroutes=yes#ipv4_failure_fatal=yes#ipv6init=no#name= "System eth1" MASTER= Bond0slave=yes 
[[Email protected] ~]# ifconfig bond0     link encap: ethernet  hwaddr 00:0c:29:00:90:1a             inet addr:10.1.70.233  Bcast:10.1.255.255  Mask:255.255.0.0           inet6 addr: fe80::20c:29ff:fe00:901a/64 scope: Link          up broadcast running master  MULTICAST  MTU:1500  Metric:1           RX packets:2990 errors:0 dropped:0 overruns:0 frame:0           TX packets:102 errors:0 dropped:0 overruns:0  carrier:0          collisions:0 txqueuelen:0            rx bytes:268909  (262.6 kib)   TX bytes:13279  (12.9  kib) eth0      link encap:ethernet  hwaddr 00:0c :29:00:90:1a            up broadcast  running slave multicast  mtu:1500  metric:1           RX packets:30770 errors:0 dropped:0 overruns:0 frame:0           TX packets:1901 errors:0 dropped:0  overruns:0 carrier:0          collisions:0  txqueuelen:1000           rx bytes:2798765  ( 2.6 MIB)   TX bytes:292096  (285.2 kib) eth1       Link encap:ethernet  hwaddr 00:0c:29:00:90:1a            up  broadcast running slave multicast  mtu:1500  metric:1           rx packets:21834 errors:0 dropped:0 overruns:0  frame:0          tx packets:11533 errors:0  dropped:0 overruns:0 carrier:0           collisions:0 txqueuelen:1000           rx  bytes:28555592  (27.2 MIB)   TX bytes:704577  (688.0 kib)







Linux network IP and bond implement multiple network cards using the same IP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.