CN102752203A - Method and network device for creating multiple virtual network interfaces - Google Patents

Method and network device for creating multiple virtual network interfaces Download PDF

Info

Publication number
CN102752203A
CN102752203A CN2012102230244A CN201210223024A CN102752203A CN 102752203 A CN102752203 A CN 102752203A CN 2012102230244 A CN2012102230244 A CN 2012102230244A CN 201210223024 A CN201210223024 A CN 201210223024A CN 102752203 A CN102752203 A CN 102752203A
Authority
CN
China
Prior art keywords
interface
virtual network
network
establishment
packet
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.)
Pending
Application number
CN2012102230244A
Other languages
Chinese (zh)
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.)
Shenzhen Coship Electronics Co Ltd
Original Assignee
Shenzhen Coship Electronics 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 Shenzhen Coship Electronics Co Ltd filed Critical Shenzhen Coship Electronics Co Ltd
Priority to CN2012102230244A priority Critical patent/CN102752203A/en
Publication of CN102752203A publication Critical patent/CN102752203A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention discloses a method for creating multiple virtual network interfaces, and the method comprises following steps of initializing device, and loading a multi-access-control virtual local area network (MACVLAN) module; creating at least one network interface by loading a network device interface; and creating multiple virtual network interfaces through the MACVLAN mechanism based on the created network interface. The embodiment of the invention also discloses a network device for creating multiple virtual network interfaces. Due to the adoption of the method and the network device, multiple virtual interfaces can be created on one physical interface.

Description

A kind of method and network equipment of creating a plurality of virtual network interfaces
Technical field
The present invention relates to the communications field, relate in particular to a kind of method and network equipment of creating a plurality of virtual network interfaces.
Background technology
In the network equipment communication, TCP/IP (Transmission Control Protocol/Internet Protocol, the transmission control protocol/internet interconnection protocol) expansion of agreement upper-layer service need depend on the bottom layer driving of network.In kernel, need to create network interface to realize function corresponding.In the existing technology, one or more physical interface is initialized as a network device interface usually in kernel.With existing many WAN (Wide Area Network on the market; Wide area network) mouthful router, many WAN mouth router can insert different outer net circuits simultaneously in order to realize, such as physical interface WAN1 meet Netcom, WAN2 connects telecommunications; Make the service of Intranet visit Netcom walk Netcom's circuit; The circuit of telecommunications is walked in the service of visit telecommunications, need on hardware, connect a plurality of physical interfaces, can adopt the switch of a plurality of RJ45 interfaces to reach the purpose of many WAN mouth like many WAN mouth router.It is thus clear that there is following defective in prior art:
1, the differentiation of business depends on the interface realization of hardware; There are a plurality of business to want to realize; Just need a plurality of physical interfaces and support, therefore limited professional diversified the development greatly, also greatly influenced the profit model and the growing demand of user of operator.
2, multiple services operation needs the realization of a plurality of physical interfaces, thereby has improved the cost of the network equipment virtually, has improved the O&M cost of operator.
Summary of the invention
Technical problem to be solved by this invention is, a kind of method and network equipment of creating a plurality of virtual network interfaces is provided, and can be implemented in and create a plurality of virtual interfaces on the physical interface.
In order to solve the problems of the technologies described above, the invention provides a kind of method of creating a plurality of virtual network interfaces, said method comprises:
Device initialize comprises loading the MACVLAN module;
Drive at least one network interface of establishment through the load networks equipment interface;
Based on the network interface that said establishment obtains, create a plurality of virtual network interfaces through MACVLAN mechanism.
Wherein, said through also comprising after a plurality of virtual network interfaces of MACVLAN mechanism establishment:
Set up the NAT mapping relations between said network interface and the said a plurality of virtual network interface.
Wherein, saidly create a plurality of virtual network interfaces through MACVLAN mechanism and comprise:
The notice chain function of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
Wherein, said through also comprising behind a plurality of virtual network interfaces of MACVLAN mechanism establishment:
Obtain the packet that needs transmission;
Calling the function of registering when creating said virtual network interface handles said packet;
Drive the treated packet of transmission through said network device interface.
Accordingly, the embodiment of the invention also provides a kind of network equipment of realizing creating a plurality of virtual network interfaces, and the said network equipment comprises:
Initialization unit is used to carry out device initialize, comprises loading the MACVLAN module;
Network interface is created the unit, is used for driving at least one network interface of establishment through the load networks equipment interface;
Virtual network interface is created the unit, is used for the network interface that obtains based on said establishment, creates a plurality of virtual network interfaces through MACVLAN mechanism.
Wherein, the said network equipment also comprises:
Mapping relations are set up the unit, are used to set up the NAT mapping relations between said network interface and the said a plurality of virtual network interface.
Wherein, said network interface is created the unit and is driven through the load networks equipment interface and create at least one network interface and comprise:
The notice chain function of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
Wherein, the said network equipment also comprises:
The packet acquiring unit is used to obtain the packet that needs send;
The processing data packets unit is used to call the function of registering when creating said virtual network interface said packet is handled;
The packet transmitting element is used for driving the treated packet of transmission through said network device interface.
Embodiment of the present invention; Has following beneficial effect: through adopting the MACVLAN mechanism of Linux; Be implemented in and create a plurality of virtual interfaces on the physical interface; Can on a plurality of virtual network interfaces that establishment obtains, carry out a plurality of business, thereby reach many nets of a line or a line multi-service, effectively reduce cost.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art; To do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below; Obviously, the accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills; Under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is a kind of schematic flow sheet of creating the method for a plurality of virtual network interfaces of the present invention;
Fig. 2 is that the present invention calls and creates the virtual network interface obtain and carry out the schematic flow sheet that packet sends;
Fig. 3 is a kind of structural representation of realizing creating the network equipment of a plurality of virtual network interfaces of the present invention.
Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Fig. 1 is a kind of schematic flow sheet of creating the method for a plurality of virtual network interfaces of the present invention.The embodiment of the invention can be implemented in as on the various network devices such as PC, router, switch, communication server.The method of creating a plurality of virtual network interfaces in the embodiment of the invention as shown in the figure comprises at least:
Step S101, device initialize comprises loading MACVLAN (Media Access Control Address based Virtual Local Area Network is based on the media access control address of VLAN) module.In concrete the realization, this step can comprise network equipment electrifying startup to loading kernel, initialization network protocol stack then, and the load document system loads the MACVLAN module of Linux.
Step S102 drives at least one network interface of establishment through the load networks equipment interface.In concrete the realization, creating network interface with router is example, loading be the associated drives of Ethernet switch, obtaining a network interface to realize creating based on a physical interface.When a plurality of physical interface, can corresponding each physical interface establishment obtain a network interface.
Step S103 based on the network interface that said establishment obtains, creates a plurality of virtual network interfaces through MACVLAN mechanism.Utilize the MACVLAN mechanism of Linux to create a plurality of virtual network interfaces, comprise in concrete the realization: after loading MACVLAN module and initialization, carry out the registration of following function based on a network interface:
The Notifier notice chain function (the processing function the during change of network equipment state) of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
After completing successfully the above-mentioned three class functions registration of MAC VLAN, promptly create successfully based on a plurality of virtual network interfaces of a network interface.
Further said a kind of method of creating a plurality of virtual network interfaces can also comprise:
Set up NAT (Network Address Translation, the network address translation) mapping relations between said network interface and the said a plurality of virtual network interface.This step is optional, for example in router, realizes setting up said NAT mapping relations in this programme, carries out network address translation in the time of can realizing the circular treatment data and transmits packet by the network interface of correspondence.
For the virtual network interface that how to use said establishment to obtain is described, the flow process of sending packet through a virtual network interface that uses said method to create and obtain is below set forth:
Fig. 2 is that the present invention calls and creates the virtual network interface obtain and carry out the schematic flow sheet that packet sends, and this flow process as shown in the figure comprises:
Step S201 obtains the packet that needs transmission.Be specially the network device interface driving and get access to the said packet that needs transmission.
Step S202 calls the function of registering when creating said virtual network interface and handles.In concrete the realization; Said network device interface drives after getting access to said packet; Can call network protocol stack handles said packet; Comprise that three types the function that succeeds in registration when creating said virtual network interface before calling handles said packet, after disposing treated packet is returned to said network device interface and drive.
Step S203 drives the treated packet of transmission through said network device interface.
Fig. 3 is a kind of structural representation of realizing creating the network equipment of a plurality of virtual network interfaces of the present invention.The network equipment among the present invention can be realized on like equipment such as PC, router, switch, communication servers.
Initialization unit 310 is used to carry out device initialize, comprises loading the MACVLAN module.Concrete, initialization unit 310 is at network equipment electrifying startup initialization network protocol stack after load kernel, and the load document system loads the MACVLAN module of Linux.
Network interface is created unit 320, is used for driving at least one network interface of establishment through the load networks equipment interface.In the concrete realization, router establishment network interface is an example, and what network interface was created unit 320 loadings is the associated drives of Ethernet switch, to realize obtaining a network interface based on a physical interface establishment.When a plurality of physical interface, network interface is created unit 320 can corresponding each physical interface establishment obtain a network interface.
Virtual network interface is created unit 330, is used for the network interface that obtains based on said establishment, creates a plurality of virtual network interfaces through MACVLAN mechanism.Utilize the MACVLAN mechanism of Linux to create a plurality of virtual network interfaces based on a network interface, comprise in concrete the realization: virtual network interface is created the registration that unit 330 carries out with minor function after loading MACVLAN module and initialization:
The Notifier notice chain function (the processing function the during change of network equipment state) of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
After completing successfully the above-mentioned three class functions registration of MAC VLAN, virtual network interface is created unit 330 and is created successfully based on a plurality of virtual network interfaces of a network interface.
The network equipment that a plurality of virtual network interfaces are created in further said realization can also comprise:
Mapping relations are set up unit 340, are used to set up the NAT mapping relations between said network interface and the said a plurality of virtual network interface.This step is optional, for example in router, realizes setting up said NAT mapping relations in this programme, carries out network address translation in the time of can realizing the circular treatment data and transmits packet by the network interface of correspondence.
The network equipment that a plurality of virtual network interfaces are created in further said realization can also comprise:
Packet acquiring unit 350 is used to obtain the packet that needs send.
Processing data packets unit 360 is used to call the function of registering when creating said virtual network interface said packet is handled.In concrete the realization; Said processing data packets unit 360 is after getting access to said packet; Can call network protocol stack handles said packet; Comprise that three types the function that succeeds in registration when creating said virtual network interface before calling handles said packet, after disposing treated packet is returned to network device interface and drive.
Packet transmitting element 370 is used for driving the treated packet of transmission through said network device interface.
The embodiment of the invention is through adopting the MACVLAN mechanism of Linux; Be implemented in and create a plurality of virtual interfaces on the physical interface; Can on a plurality of virtual network interfaces that establishment obtains, carry out a plurality of business, thereby reach many nets of a line or a line multi-service, effectively reduce cost.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in the foregoing description method; Be to instruct relevant hardware to accomplish through computer program; Described program can be stored in the computer read/write memory medium; This program can comprise the flow process like the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-Only Memory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
Above disclosedly be merely preferred embodiment of the present invention, can not limit the present invention's interest field certainly with this, the equivalent variations of therefore doing according to claim of the present invention still belongs to the scope that the present invention is contained.

Claims (8)

1. method of creating a plurality of virtual network interfaces is characterized in that said method comprises:
Device initialize comprises loading the MACVLAN module;
Drive at least one network interface of establishment through the load networks equipment interface;
Based on the network interface that said establishment obtains, create a plurality of virtual network interfaces through MACVLAN mechanism.
2. the method for a plurality of virtual network interfaces of establishment as claimed in claim 1 is characterized in that, and is said through also comprising after a plurality of virtual network interfaces of MACVLAN mechanism establishment:
Set up the NAT mapping relations between said network interface and the said a plurality of virtual network interface.
3. the method for a plurality of virtual network interfaces of establishment as claimed in claim 1 is characterized in that, saidly creates a plurality of virtual network interfaces through MACVLAN mechanism and comprises:
The notice chain function of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
4. the method for a plurality of virtual network interfaces of establishment as claimed in claim 3 is characterized in that, and is said through also comprising behind a plurality of virtual network interfaces of MACVLAN mechanism establishment:
Obtain the packet that needs transmission;
Calling the function of registering when creating said virtual network interface handles said packet;
Drive the treated packet of transmission through said network device interface.
5. a network equipment of realizing creating a plurality of virtual network interfaces is characterized in that, the said network equipment comprises:
Initialization unit is used to carry out device initialize, comprises loading the MACVLAN module;
Network interface is created the unit, is used for driving at least one network interface of establishment through the load networks equipment interface;
Virtual network interface is created the unit, is used for the network interface that obtains based on said establishment, creates a plurality of virtual network interfaces through MACVLAN mechanism.
6. the network equipment of a plurality of virtual network interfaces is created in realization as claimed in claim 5, it is characterized in that, also comprises:
Mapping relations are set up the unit, are used to set up the NAT mapping relations between said network interface and the said a plurality of virtual network interface.
7. create the network equipment of a plurality of virtual network interfaces like claim 5 or 6 described realizations, it is characterized in that, said network interface is created the unit and is driven through the load networks equipment interface and create at least one network interface and comprise:
The notice chain function of registration MAC VLAN interface;
The frame-handling function of registration MAC VLAN interface;
The linked operation function of registration MAC VLAN interface.
8. the network equipment of a plurality of virtual network interfaces is created in realization as claimed in claim 7, it is characterized in that, also comprises:
The packet acquiring unit is used to obtain the packet that needs send;
The processing data packets unit is used to call the function of registering when creating said virtual network interface said packet is handled;
The packet transmitting element is used for driving the treated packet of transmission through said network device interface.
CN2012102230244A 2012-06-30 2012-06-30 Method and network device for creating multiple virtual network interfaces Pending CN102752203A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2012102230244A CN102752203A (en) 2012-06-30 2012-06-30 Method and network device for creating multiple virtual network interfaces

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2012102230244A CN102752203A (en) 2012-06-30 2012-06-30 Method and network device for creating multiple virtual network interfaces

Publications (1)

Publication Number Publication Date
CN102752203A true CN102752203A (en) 2012-10-24

Family

ID=47032107

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2012102230244A Pending CN102752203A (en) 2012-06-30 2012-06-30 Method and network device for creating multiple virtual network interfaces

Country Status (1)

Country Link
CN (1) CN102752203A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103391217A (en) * 2013-07-24 2013-11-13 深信服网络科技(深圳)有限公司 Method for realizing synchronization of heterogeneous cluster devices, and heterogeneous cluster system
CN105405280A (en) * 2015-10-22 2016-03-16 宁波三星医疗电气股份有限公司 Realization method for debugging electric power acquisition terminal and obtaining meter reading information
CN106982170A (en) * 2017-04-19 2017-07-25 上海海加网络科技有限公司 Multi-link load balance method and device based on linux system
CN111147391A (en) * 2019-12-05 2020-05-12 深圳市任子行科技开发有限公司 Data transmission method and system between DPDK user mode and linux kernel network protocol stack

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1703016A (en) * 2003-03-06 2005-11-30 微软公司 Virtual network topology generation
CN101322432A (en) * 2006-09-20 2008-12-10 香港应用科技研究院有限公司 Method of seamlessly roaming between multiple wireless networks using a single wireless network adaptor
CN102025787A (en) * 2010-11-22 2011-04-20 中兴通讯股份有限公司 Method and device for accessing network by network interface of data card equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1703016A (en) * 2003-03-06 2005-11-30 微软公司 Virtual network topology generation
CN101322432A (en) * 2006-09-20 2008-12-10 香港应用科技研究院有限公司 Method of seamlessly roaming between multiple wireless networks using a single wireless network adaptor
CN102025787A (en) * 2010-11-22 2011-04-20 中兴通讯股份有限公司 Method and device for accessing network by network interface of data card equipment

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103391217A (en) * 2013-07-24 2013-11-13 深信服网络科技(深圳)有限公司 Method for realizing synchronization of heterogeneous cluster devices, and heterogeneous cluster system
CN103391217B (en) * 2013-07-24 2016-08-10 深信服网络科技(深圳)有限公司 Realize method and Heterogeneous Cluster Environment that isomeric group equipment synchronizes
CN105405280A (en) * 2015-10-22 2016-03-16 宁波三星医疗电气股份有限公司 Realization method for debugging electric power acquisition terminal and obtaining meter reading information
CN105405280B (en) * 2015-10-22 2018-11-30 宁波三星医疗电气股份有限公司 A kind of implementation method for debugging electric power acquisition terminal and obtaining amr message
CN106982170A (en) * 2017-04-19 2017-07-25 上海海加网络科技有限公司 Multi-link load balance method and device based on linux system
CN111147391A (en) * 2019-12-05 2020-05-12 深圳市任子行科技开发有限公司 Data transmission method and system between DPDK user mode and linux kernel network protocol stack
CN111147391B (en) * 2019-12-05 2023-04-07 深圳市任子行科技开发有限公司 Data transmission method and system between DPDK user mode and linux kernel network protocol stack

Similar Documents

Publication Publication Date Title
EP2586160B1 (en) Distributed virtual network gateways
US8601158B2 (en) Virtual gateway router
US9876756B2 (en) Network access method and device for equipment
EP2842285A1 (en) Migration of a security policy of a virtual machine
CN106464534A (en) Provisioning and managing slices of consumer premises equipment device
CN104919762B (en) Control method in software defined network, controls equipment and processor
CN103270507A (en) Integrated software and hardware system that enables automated provisioning and configuration of a blade based on its physical location
CN104426680A (en) Data transmission method, device and system
CN1832458B (en) Method for facilitating application server functionality and access node comprising same
CN102845123A (en) Virtual private cloud connection method and tunnel proxy server
CN104869063A (en) Host route processing method in virtual subnet, related devices and communication system
CN102752203A (en) Method and network device for creating multiple virtual network interfaces
CN104506368B (en) A kind of method and apparatus for being managed collectively switch device
CN108833472A (en) System is established in the connection of cloud host
CN108540588A (en) MAC Address acquisition methods and system, Network Security Device and readable storage medium storing program for executing
CN109756359A (en) The method and remote server and network system of auto-initiation network equipment
EP3964970B1 (en) Heterogeneous and/or hosted physical layer management system
CN105827496B (en) Manage the method and device of PE equipment
CN103141072B (en) IP address acquiring method and network access equipment
CN105573801A (en) Method for realizing software upgrading in stacking system as well as device and system
CN102761629A (en) Method, device and system for setting DNS (Domain Name System) server address
CN105577433A (en) ACS cluster management method, apparatus and system
US6839764B2 (en) Domain encapsulation
CN109462535A (en) A kind of message processing method and device
CN109756454A (en) The methods, devices and systems of data interaction

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C12 Rejection of a patent application after its publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20121024