Linux IP alias and multi-nic binding

Source: Internet
Author: User
(I) Advanced Nic commands

① MiI-tool eth0: view the NIC status

② Ethtool view Nic settings

Ethtool-I eth0: view the driver of the NIC
Ethtool eth0: view the physical characteristics of the network card
Ethtool-s eth0: view the underlying status of the NIC


(Ii) IP alias

Multiple IP addresses are configured on a physical network card to implement functions such as sub-interfaces, which are called IP aliases.
When a Linux DHCP server allocates different IP addresses to multiple CIDR blocks or a Linux router, you may need to configure multiple IP addresses on one physical interface.

(1) step_1
RedHat uses NetworkManager to manage NICs by default, but only supports the most basic functions.

To bind an IP alias or multiple NICs, disable this feature.

[Root @ localhost ~] # Service NetworkManager stop the NetworkManager daemon: [OK] [root @ localhost ~] # Chkconfig NetworkManager off [root @ localhost ~] # Service NetworkManager statusnetworkmanager is stopped

(2) step_2

[root@localhost ~]# ifconfig eth0eth0      Link encap:Ethernet  HWaddr 00:0C:29:5E:10:AB          inet addr:192.168.1.112  Bcast:255.255.255.255  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:576  Metric:1          RX packets:520 errors:0 dropped:0 overruns:0 frame:0          TX packets:287 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:82430 (80.4 KiB)  TX bytes:35734 (34.8 KiB)[root@localhost ~]# ip addr add 192.168.1.200/24 dev eth0 label eth0:0[root@localhost ~]# ifconfigeth0      Link encap:Ethernet  HWaddr 00:0C:29:5E:10:AB          inet addr:192.168.1.112  Bcast:255.255.255.255  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:576  Metric:1          RX packets:700 errors:0 dropped:0 overruns:0 frame:0          TX packets:395 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:105711 (103.2 KiB)  TX bytes:48168 (47.0 KiB)eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:5E:10:AB          inet addr:192.168.1.200  Bcast:0.0.0.0  Mask:255.255.255.0          UP BROADCAST RUNNING MULTICAST  MTU:576  Metric:1


If you want to add an IP alias permanently, you can add the alias configuration file under/etc/sysconfig/network-scripts:
Configuration File Name:
Ifcfg-eth0: 0
Content:
Device = eth0: 0
Ipaddr = 192.168.1.200
Prefix = 24 // Subnet Mask
Onparent = Yes // dependency



(3) bind multiple NICs

Linux allows you to bind multiple physical NICs to one logical Nic to improve bandwidth and stability.
The bound physical Nic is not directly used.
The IP address is configured on the bound logical Nic.
WLAN cannot be bound
Nic binding mode:
Mode 0: balanced round robin
-- Increase bandwidth
Mode 1: active backup
-- Increase stability by using only one network card
Mode 2: Broadcast
-- Generally not used
The bound logical Nic is named bondn and N is numbered, such as/dev/bond0 and/dev/bond1.

If the two NICs are on different routers, that is, in different network segments, you cannot use Nic binding to increase the bandwidth.
If the server has two addresses connected to different network segments, the easiest way for the client to perform LB when accessing the server is to use DNS for load balancing.
The client accesses the server through the domain name, And the DNS resolves the domain name to the IP addresses of the two NICs of the specified server.

(1) step_1

Create a logical Nic configuration file:
/ETH/sysconfig/network-scripts/ifcfg-bond0

Device = bond0
Ipaddr = 192.168.1.200
Prefix = 24
Onboot = Yes
Bootproto = none
Userctl = No
Bonding_opts = "mode = 0 miimon = 50"

(2) step_2

Stop each network card first: ifdown eth0, eth1
Then modify the configuration file of each physical NIC that belongs to the logical NIC:
/Etc/sysconfig/network-scripts/ifcfg-eth0

Device = eth0
Bootproto = none
Onboot = Yes
Master = bond0
Slave = Yes
Userctl = No
The second network card, eth1

(3) step_3

Add driver
/Etc/modprobe. d/bonding. conf

Alias bond0 Bonding


(4) step_4

Service Network stop
Service Network start
IFUP bond0
Watch-N 1 ifconfig

Related Article

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.