CN105872129A - Method for realizing multi-NC (Network Card) extranet communication of Linux virtual machine - Google Patents

Method for realizing multi-NC (Network Card) extranet communication of Linux virtual machine Download PDF

Info

Publication number
CN105872129A
CN105872129A CN201610402379.8A CN201610402379A CN105872129A CN 105872129 A CN105872129 A CN 105872129A CN 201610402379 A CN201610402379 A CN 201610402379A CN 105872129 A CN105872129 A CN 105872129A
Authority
CN
China
Prior art keywords
virtual machine
network interface
intranet
outer net
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201610402379.8A
Other languages
Chinese (zh)
Other versions
CN105872129B (en
Inventor
熊梦
杨松
季统凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
G Cloud Technology Co Ltd
Original Assignee
G Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by G Cloud Technology Co Ltd filed Critical G Cloud Technology Co Ltd
Priority to CN201610402379.8A priority Critical patent/CN105872129B/en
Publication of CN105872129A publication Critical patent/CN105872129A/en
Application granted granted Critical
Publication of CN105872129B publication Critical patent/CN105872129B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5038Address allocation for local use, e.g. in LAN or USB networks, or in a controller area network [CAN]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5076Update or notification mechanisms, e.g. DynDNS

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to the technical field of cloud computation, in particular to a method for realizing multi-NC (Network Card) extranet communication of a Linux virtual machine. The method mainly comprises the following steps of creating intranet NCs for the virtual machine by a cloud platform; binding dynamic IP (Internet Protocol) addresses; then controlling to execute a script in the Linux virtual machine to complete the following operation: firstly scanning and saving IP information of the multiple NCs of the virtual machine, continuously scanning and saving gateway information of the virtual machine, and finally creating a routing list for each NC and writing in a routing rule. According to the method for realizing the multi-NC extranet communication of the Linux virtual machine, disclosed by the invention, the problem of no network access after the multiple intranet NCs are accessed to a single virtual machine in the cloud platform at the same time and are respectively subjected to dynamic IP address binding is solved; the method can be applicable to the multi-NC extranet communication of the Linux virtual machine.

Description

A kind of Linux virtual machine many network interface cards outbound communication implementation method
Technical field
The present invention relates to field of cloud computer technology, particularly a kind of Linux virtual machine many network interface cards outbound communication implementation method.
Background technology
During user uses virtual machine in cloud platform, a lot of in the case of need to add polylith network interface card for virtual machine, And be every piece of network interface card distribution Intranet IP.When user needs to carry out Intranet IP with outbound communication, then can divide for each Intranet IP Join Floating IP address and be DNAT.Although but DNAT can succeed under default situations, but can only be that a Floating IP address is effective, it is impossible to protect Card can access each Floating IP address from the outside.
Qemu Guest Agent
Qemu Guest Agent, is called for short qga, is that a common applications operating in virtual machine internal (can perform File name is defaulted as qemu-ga, and service name is defaulted as qemu-guest-agent), its objective is to realize a kind of host The mode interacted with virtual machine, this mode does not relies on network, and is to rely on virtio-serial (acquiescence first-selection Mode) or isa-serial, QEMU then provide the simulation of serial equipment and the passage of data exchange, finally present Be a serial equipment (virtual machine internal) and unix socket file (on host).
Qga is interacted with the socket passage on host by read and write serial port equipment, host can use general Socket file is written and read by logical unix socket read-write mode, and final realization is mutual with qga's.
Summary of the invention
Present invention solves the technical problem that and be to provide a kind of Linux virtual machine many network interface cards outbound communication implementation method, with Box lunch user is after adding polylith network interface card with virtual machine and be DNAT with outer net Floating IP address, it is ensured that each Floating IP address is can Proper communication.
The present invention solves the technical scheme of above-mentioned technical problem,
It is that virtual machine adds Intranet network interface card and is DNAT with outer net Floating IP address by cloud platform, then utilizes qemu-agent Control to call the virtual machine above host and perform particular script, create routing table by script and interpolation rule realizes virtual machine The success of many network interface cards communicates with outer net.
Described qemu-agent refers to Qemu Guest Agent, is a common application operating in virtual machine internal Program, its objective is to realize a kind of host and mode that virtual machine interacts, and this mode does not relies on network;
The IP of a described Floating IP address that is outer net network, it is virtual that described floating refers to that this IP can successively bind to multiple stage Machine uses;
Described DNAT refers to map an outer net IP and Intranet IP one by one, accesses outer net IP from the outside i.e. Intranet IP of this virtual machine can be had access to;Inside virtual machine, turn outer net IP by Intranet IP then can access outer net, i.e. Realize the outbound communication to virtual machine.
Described cloud platform is multiple Intranet network interface cards of virtual machine creating in private network and distributes Intranet IP;For in every Intranet IP of net network interface card and outer net IP are DNAT;Call virtual machine by host and perform network configuration script.
Described virtual machine performs particular script operation:
Scan the IP information of many network interface cards inside virtual machine and preserve;
Scanning virtual machine gateway information also preserves;
For often throwing the net, card creates routing table and writes routing rule.
Inside described scanning virtual machine, the IP information of many network interface cards refers to according to performing the orders such as ifconfig or ip Network interface card information is found in output filtering, and the information such as IP, subnet mask, network of extracting preserve;
Described scanning virtual machine gateway information refers to according to the output filtering performing the orders such as route or ip route Find default gateway and specify network interface card gateway information, extracting gateway IP information and preserve;
Described create routing table for card of often throwing the net and write routing rule and include: in specific file, writing routing table Title;The route that this network interface card preserves is added to described routing table;The gateway that this network interface card preserves is added to described routing table;
Described specific file is /etc/iproute2/rt_tables.
The present invention program has the beneficial effect that:
1, the method for the present invention can be implemented in when cloud platform user for virtual machine interpolation polylith network interface card and floats with outer net After IP is DNAT, it is ensured that each Floating IP address is can proper communication.
2, the inventive method can be simple and convenient with on fast integration to existing cloud platform.
3, the method for the present invention ensure that virtual machine can complete many network interface cards network configuration without restarting.
Accompanying drawing explanation
The present invention is further described below in conjunction with the accompanying drawings:
Fig. 1 is the flow chart of the present invention;
Fig. 2 is the network topological diagram of the present invention.
Detailed description of the invention
Refer to Fig. 1, for the flow process of a kind of Linux virtual machine many network interface cards outer net communication method that the embodiment of the present invention provides Schematic diagram.First we need to do following preparation inside virtual machine master mirror image:
1, registration qemu guest agent Agent is installed, and is start by qemu-guest-agent service configuration Start.
2, the realization of virtual machine many network card configurations script is saved under the particular category of mother matrix mirror image.
3, in/etc/iproute2/rt_tables, routing table is added the most in advance.
We specifically describe many network card configurations script route-setup.py below:
Utilize the output scanning performing ifconfig order to obtain the network interface card inside virtual machine, and preserve network interface card name, ip, Gaeway, network information, specific code is as follows:
Wherein the acquisition methods of gateway gateway is as follows:
By performing the output that order route obtains, traverse scanning obtains the gateway of each network interface card the most successively.
The acquisition code obtaining network is as follows:
The last many network interface cards information preserved for upper Surface scan, utilizes for circulation create routing table and add routing rule And gateway, specific code is as follows:
Wherein exec_command function is as follows:
Def exec_command (command):
os.system(command)
The network configuration of many network interface cards inside linux virtual machine can be completed, it is ensured that virtual machine by the execution of above-mentioned script Each network interface card carries out outbound communication.
Being ready to inside virtual machine, remaining is exactly to distribute Intranet for multiple Intranet network interface cards of virtual machine creating in cloud platform IP, is then distributed multiple outer net floating ip and is DNAT, DNAT one by one and is realized by iptables, not describing in detail.
In cloud platform, controlled the execution of script afterwards by host, present invention utilizes qemu-agent and realize, Specifically it is through on the host at virtual machine place performing as ordered:
Virsh qemu-agent-command i-xxxxxx ' { " execute ": " guest-exec ", " Arguments ": { " path ": " python ", " arg ": ["/root/route-setup.py "] }
As above i-xxxxxxxx represents virtual machine ID.Utilization changes order and realizes controlling virtual machine execution/root/route- Setup.py script completes many network interface cards network configuration.

Claims (6)

1. Linux virtual machine many network interface cards outbound communication implementation method, it is characterised in that: by cloud platform be virtual machine add Intranet network interface card is also DNAT with outer net Floating IP address, then utilizes qemu-agent to control to call the virtual machine above host and performs Particular script, creates routing table by script and interpolation rule realizes the success of virtual machine many network interface cards and communicates with outer net.
Method the most according to claim 1, it is characterised in that described qemu-agent refers to Qemu Guest Agent, is a common applications operating in virtual machine internal, its objective is to realize a kind of host and virtual machine is carried out Mutual mode, this mode does not relies on network;
The IP of a described Floating IP address that is outer net network, described floating refers to that this IP can successively bind to be made to multiple stage virtual machine With;
Described DNAT refers to map an outer net IP and Intranet IP one by one, accesses outer net IP from the outside the most permissible Have access to Intranet IP of this virtual machine;Inside virtual machine, turn outer net IP by Intranet IP then can access outer net, i.e. realize Outbound communication to virtual machine.
Implementation method the most according to claim 1, it is characterised in that described cloud platform is virtual machine in private network Create multiple Intranet network interface cards and distribute Intranet IP;Intranet IP and outer net IP for every Intranet network interface card are DNAT;Pass through host Call virtual machine and perform network configuration script.
Implementation method the most according to claim 2, it is characterised in that described cloud platform is virtual machine in private network Create multiple Intranet network interface cards and distribute Intranet IP;Intranet IP and outer net IP for every Intranet network interface card are DNAT;Pass through host Call virtual machine and perform network configuration script.
5. according to the method described in any one of Claims 1-4, it is characterised in that described virtual machine performs particular script fortune Row is:
Scan the IP information of many network interface cards inside virtual machine and preserve;
Scanning virtual machine gateway information also preserves;
For often throwing the net, card creates routing table and writes routing rule.
Method the most according to claim 5, it is characterised in that inside described scanning virtual machine, the IP information of many network interface cards is Refer to find network interface card information according to the output filtering performing the orders such as ifconfig or ip, extract the letters such as IP, subnet mask, network Breath preserves;
Described scanning virtual machine gateway information refers to that the output filtering according to performing the orders such as route or ip route is found Default gateway and appointment network interface card gateway information, extract gateway IP information and preserve;
Described create routing table for card of often throwing the net and write routing rule and include: write route table name in specific file Claim;The route that this network interface card preserves is added to described routing table;The gateway that this network interface card preserves is added to described routing table;
CN201610402379.8A 2016-06-07 2016-06-07 A kind of more network interface card outbound communication implementation methods of Linux virtual machine Active CN105872129B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610402379.8A CN105872129B (en) 2016-06-07 2016-06-07 A kind of more network interface card outbound communication implementation methods of Linux virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610402379.8A CN105872129B (en) 2016-06-07 2016-06-07 A kind of more network interface card outbound communication implementation methods of Linux virtual machine

Publications (2)

Publication Number Publication Date
CN105872129A true CN105872129A (en) 2016-08-17
CN105872129B CN105872129B (en) 2019-04-26

Family

ID=56677300

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610402379.8A Active CN105872129B (en) 2016-06-07 2016-06-07 A kind of more network interface card outbound communication implementation methods of Linux virtual machine

Country Status (1)

Country Link
CN (1) CN105872129B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453616A (en) * 2016-11-15 2017-02-22 国云科技股份有限公司 File-based method for communication between virtual machine and host machine
CN106844066A (en) * 2017-01-22 2017-06-13 腾讯科技(深圳)有限公司 One kind application operation method, apparatus and system
CN107147533A (en) * 2017-05-31 2017-09-08 郑州云海信息技术有限公司 A kind of flow table configuration distributing method and system based on SDN frameworks
CN108696394A (en) * 2018-05-18 2018-10-23 深圳市智微智能科技开发有限公司 The means of communication and equipment of multiple PCIE network interface cards under a kind of Linux system
CN109684035A (en) * 2018-12-17 2019-04-26 武汉烽火信息集成技术有限公司 A kind of adaptive virtual machine and host communication means and system
CN110798491A (en) * 2018-08-01 2020-02-14 北京国双科技有限公司 Network access method and device and proxy server
CN112565357A (en) * 2020-11-25 2021-03-26 中国银联股份有限公司 Method, device and storage medium for connecting service virtual machine and object storage system
CN113645057A (en) * 2021-06-25 2021-11-12 济南浪潮数据技术有限公司 Method and device for supporting addition of network card model by cloud platform
CN114448934A (en) * 2021-12-31 2022-05-06 苏州浪潮智能科技有限公司 Method and device for high availability of floating internet protocol address

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110277028A1 (en) * 2010-05-10 2011-11-10 Canon Kabushiki Kaisha Assigning a network address for a virtual device to virtually extend the functionality of a network device
CN103812704A (en) * 2014-02-25 2014-05-21 国云科技股份有限公司 Public network IP (Internet Protocol) dynamic management method for virtual machine
CN104270464A (en) * 2014-10-22 2015-01-07 西安未来国际信息股份有限公司 Cloud computing virtualized network architecture and optimization method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110277028A1 (en) * 2010-05-10 2011-11-10 Canon Kabushiki Kaisha Assigning a network address for a virtual device to virtually extend the functionality of a network device
CN103812704A (en) * 2014-02-25 2014-05-21 国云科技股份有限公司 Public network IP (Internet Protocol) dynamic management method for virtual machine
CN104270464A (en) * 2014-10-22 2015-01-07 西安未来国际信息股份有限公司 Cloud computing virtualized network architecture and optimization method

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106453616A (en) * 2016-11-15 2017-02-22 国云科技股份有限公司 File-based method for communication between virtual machine and host machine
CN106844066B (en) * 2017-01-22 2022-09-27 腾讯科技(深圳)有限公司 Application operation method, device and system
CN106844066A (en) * 2017-01-22 2017-06-13 腾讯科技(深圳)有限公司 One kind application operation method, apparatus and system
CN107147533A (en) * 2017-05-31 2017-09-08 郑州云海信息技术有限公司 A kind of flow table configuration distributing method and system based on SDN frameworks
CN108696394A (en) * 2018-05-18 2018-10-23 深圳市智微智能科技开发有限公司 The means of communication and equipment of multiple PCIE network interface cards under a kind of Linux system
CN110798491B (en) * 2018-08-01 2022-10-28 北京国双科技有限公司 Network access method and device and proxy server
CN110798491A (en) * 2018-08-01 2020-02-14 北京国双科技有限公司 Network access method and device and proxy server
CN109684035B (en) * 2018-12-17 2020-11-17 武汉烽火信息集成技术有限公司 Self-adaptive virtual machine and host machine communication method and system
CN109684035A (en) * 2018-12-17 2019-04-26 武汉烽火信息集成技术有限公司 A kind of adaptive virtual machine and host communication means and system
CN112565357A (en) * 2020-11-25 2021-03-26 中国银联股份有限公司 Method, device and storage medium for connecting service virtual machine and object storage system
CN113645057A (en) * 2021-06-25 2021-11-12 济南浪潮数据技术有限公司 Method and device for supporting addition of network card model by cloud platform
CN113645057B (en) * 2021-06-25 2023-04-07 济南浪潮数据技术有限公司 Method and device for supporting addition of network card model by cloud platform
CN114448934A (en) * 2021-12-31 2022-05-06 苏州浪潮智能科技有限公司 Method and device for high availability of floating internet protocol address
CN114448934B (en) * 2021-12-31 2023-08-04 苏州浪潮智能科技有限公司 Method and device for high availability of floating internet protocol address

Also Published As

Publication number Publication date
CN105872129B (en) 2019-04-26

Similar Documents

Publication Publication Date Title
CN105872129A (en) Method for realizing multi-NC (Network Card) extranet communication of Linux virtual machine
CN110232036A (en) Host system and its method and accelerating module
CN103346981B (en) Virtual switch method, relevant apparatus and computer system
US9658873B2 (en) Switching between devices having a common host backend in a virtualized environment
CN103475704B (en) A kind of method for virtual node configuration of Virtual group of planes application
CN105283855B (en) A kind of addressing method and device
CN106878482B (en) Network address translation method and device
CN103703441B (en) Hard disk and data processing method
US20160117231A1 (en) Complex Network Modeling For Disaster Recovery
CN106487850A (en) The methods, devices and systems of mirror image are obtained under a kind of cloud environment
CN105490910B (en) Network communication method and client
US9697144B1 (en) Quality of service enforcement and data security for containers accessing storage
CN103942087A (en) Virtual machine thermal migration method, related device and cluster computing system
US9454394B2 (en) Hypervisor dynamically assigned input/output resources for virtual devices
CN105635332A (en) Method for multiple virtual machines to share IP of single external network
CN103905312B (en) IPv6/IPv4 protocol translations gateway and data message processing method
CN111130838A (en) Method and device for dynamic expansion of process-level service instance and network bandwidth limitation
CN106484327B (en) A kind of data processing method and associated storage device
CN109981493A (en) A kind of method and apparatus for configuring virtual machine network
CN116830084A (en) Service network method for dynamic container network management
CN106411742B (en) A kind of method and apparatus of message transmissions
CN109995814A (en) Moving method and device, communication equipment, the storage medium of cloud host resource
CN115622878A (en) Method and device for realizing k8s network bridge plug-in, electronic equipment and readable storage medium
CN110247807A (en) A kind of port management method and device
US10834018B2 (en) Distributed computing acceleration platform and distributed computing acceleration platform operation method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 523808 19th Floor, Cloud Computing Center, Chinese Academy of Sciences, No. 1 Kehui Road, Songshan Lake Hi-tech Industrial Development Zone, Dongguan City, Guangdong Province

Applicant after: G-Cloud Technology Co., Ltd.

Address before: 523808 No. 14 Building, Songke Garden, Songshan Lake Science and Technology Industrial Park, Dongguan City, Guangdong Province

Applicant before: G-Cloud Technology Co., Ltd.

GR01 Patent grant
GR01 Patent grant