Network Fundamentals
Bonging NIC Bindings
1. Network Fundamentals
In the existing learning phase, if you test the network and the basic is through the ping command ( in the production environment in order to prevent attacks almost all of the servers are banned ping), but it is often unclear what the command is doing behind the scenes, well, look down on the right
1.1Routing/Routers:The router (Router) is also known asGateway Devices(Gateway) is used to connect multiple logically separated networks, so-called logical networks represent a single network or aSub-Network. When data is transferred from one subnet to another subnet, it can be done through the router's routing capability. Therefore, the router has a judgmentNetwork addressand select IPPathfunction, it can be in manyNetwork interconnectionenvironment, a flexible connection can be established, using a completely different data grouping andMediumaccess Methods connect a variety of subnets, the router only accepts the source station or otherRouterthe information, belong toInternetlayer of a connected device. (this article from Baidu Encyclopedia) In layman's words, when a network request occurs, routing is the realization of "how to find the road" function
1.2 Gateway : The gateway is the default data export. If your data doesn't know where to go, then he'll go to the default gateway to report it. Routers contain many of these gateways, one of which is the default gateway. In other words, after the data to the router, if you do not know how to go to the next step, then he will go to the default gateway to report
Icon:
Take Route1 as an example, PC1 to communicate with PC2, you must go ROUTE1/2/3, but now these three routers do not know how to go, because the router inside to have a " route entry " This route entry is recorded "where the packet from where to pass to the , the process from where to go "such information, so
(1) ROUTE1 Configuration Routing entry: "Route" from Route1 to PC2
Route add-net 4.4.4.0/24 GW 2.2.2.252
(3) ROUTE1 Configuration Routing entry: "Route" from Route1 to Route3
Route add-net 3.3.3.0/24 GW 2.2.2.252
In the same vein, each router (route) is configured with the corresponding " Destination address and gateway entry "
Take Route1 as an example to write two route entries, this is the simplest network communication model, of course, in real life or production environment obviously there is no such a simple route, there may be many routes, there are several routes, switches and so on. Do you want to add a route entry for each of the multiple routes or hosts?
Obviously this is unrealistic, and secondly, too many routing entries can cause less communication efficiency, so this routing entry simplifies
In the figure, route1 two entries although the destination is not one, but these two items are in the same direction, are from the left and right, so you can write:
Route add-net default GW 2.2.2.252
To view the route entry:
Route-n
There is the deletion of the addition, just need to change the corresponding "add" to "Del" can
The example in the figure can be interpreted as "all routes to PC2 direction execute this entry and specify gateway to 2.2.2.252"
As the routing entry is simplified, the scope of the search becomes smaller and the efficiency is naturally higher.
The above "small experiment" is on the VMware virtual machine, with five virtual machines, if the virtual machine is cloned need to pay attention to the network card profile name and MAC address problems
Nic configuration file directory:
/etc/sysconfig/network-scripts
The file named "ifcfg-" is the network card configuration file, when it comes to the network card configuration file, then simply look at it:
device=eth1 #设备名称, is the name of the device in the ifconfig command list type=ethernet #类型为以太网UUID =9b86924e-c19c-46fc-8fb7-ab2239fb22cb #系统中设备的唯一标识ONBOOT =yes #是否开机启动NM_CONTROLLED =yes #是否启用NetworkManager管理工具 (CENTOS6 "No" is recommended in , otherwise it is easy to get rid of DHCP by this service when setting up static IP bootproto=dhcp #做网卡绑定的时候常用, DHCP or static type, If you do not specify, you are prone to restricted access issues HWADDR=00:0C:29:E6:8B:2D &NBsp; #MAC地址, the world's only device identification prefix=16 #子网掩码
If you need to set the specified static IP, add a "ipaddr=xxx.xxx.xxx.xxx" to the above and specify Bootproto as static
Of course, the configuration of the network adapter is still a lot of commands, similar to Ifconfig/netstat (click to view the command) is a long time ago the command set, just because the habit of most people still use
Many times the network card service restarts when many features do not take effect, this time need to uninstall/reinstall NIC driver module
Query NIC module Name:
Ethtool-i eth0 #eth0为ifconfig命令查询出来的网卡名
Unloading:
Modprobe-r Pcnet32 #pcnet32为上一条命令查询出来的结果
Loading:
Modprobe Pcnet32 #上一条命令去掉-R
2.Bonding
2.1 bonding (binding) is a Linux system NIC Binding technology
Bonding technology is implemented at the kernel level of the Linux system, which is a kernel module (driver). Using it requires the system to have this module, we can modinfo command to view the information of this module, generally support
In layman's terms, two or more physical network cards are bonding virtual into a network card, and given an IP address, can carry more data traffic, and inHighly AvailableAspect has a great effect, one piece out of the fault can be done by other network adapter, of course, this process more or less has a time interval, not clear maximum can allow the process of the execution time, but it is certain that if the data traffic is large, bonding insideslow processing failure is bound to drop packets.,However, this refresh interval is too short, too fast and will take up too much system resources, so this point in time to masterIn additionthis time through the bonding configuration file inside the Miimon option assignment control, the unit is Ms), in implementingLoad BalancingAspect also has the very big ability, one piece of network card traffic is too big, through bonding can share part or most
1.mode 0 (BALANCE-RR) rotation (round-robin) Policy: sends packets above and below each slave interface in a sequential order. This mode provides the ability to load balance and fault tolerance
mode 1 (active-backup) activity-Backup (master Standby) policy: Only one slave is activated, and other slave is activated only if the active slave interface fails. To avoid confusion on the switch, the bound MAC address is visible on only one external port
3.mode 3 (broadcast) broadcast policy: All messages are transmitted on all slave interfaces, providing fault tolerance
4.active-backup, Balance-tlb, and BALANCE-ALB modes do not require any special configuration of the switch. Other binding modes require the switch to be configured to consolidate the links. Example: Cisco switches need to use EtherChannel in modes 0, 2, and 3, but LACP and EtherChannel are required in mode 4
2.2Bonding configuration file
2.2.1 Creating a bonding file
Vim/etc/sysconfig/network-scripts/ifcfg-bond0 device=bond0 bonding_opts= "mode=1 miimon=100" #mode1模式/Refresh one every 100ms Times Ipaddr=xxx.xxx.xxx.xxx prefix=24 #子网掩码
2.2.2 Configuring the relationship between the physical NIC and bond0
Device=eth3 #要配置的网卡名称MASTER =bond0 #网卡属于哪个bond0SLAVES =yes #隶属关系是否开启 (yes Bond0 can manage this NIC, no is reversed)
* Similarly set up another or more network cards for this configuration form
2.2.3 in CENTOS6, it is recommended to close the NetworkManager management tool
/etc/init.d/networkmanager stop
Restart Network Service:
/etc/init.d/network Restart #或者执行: Service network restart
To view the status of Bond0:
Cat/proc/net/bonding
To view the operating mode of the BOND0:
Cat/sys/class/net/bond0
Summary bonding:
In the actual production environment, bonding may not more than two or three network card, because the server needs to be stable, high availability, guaranteed not to lose packets is fundamental, so there will be a lot of network card composition bond, the process, the application layer is not feel the change of network card, as long as the value of Miiimon is not too large, refresh frequency not too slow, Will not lose the package, you can not find anything, so it is a good solution to the network card failure to ensure the normal operation of the system measures.
The basic of network communication model and the concept and usage of high availability/bonding under Linux