CN109327394B - A kind of message forwarding method and device - Google Patents

A kind of message forwarding method and device Download PDF

Info

Publication number
CN109327394B
CN109327394B CN201811435603.9A CN201811435603A CN109327394B CN 109327394 B CN109327394 B CN 109327394B CN 201811435603 A CN201811435603 A CN 201811435603A CN 109327394 B CN109327394 B CN 109327394B
Authority
CN
China
Prior art keywords
message
address
interface
user
gateway
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.)
Active
Application number
CN201811435603.9A
Other languages
Chinese (zh)
Other versions
CN109327394A (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.)
Beijing H3C Technologies Co Ltd
Original Assignee
Beijing H3C Technologies 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 Beijing H3C Technologies Co Ltd filed Critical Beijing H3C Technologies Co Ltd
Priority to CN201811435603.9A priority Critical patent/CN109327394B/en
Publication of CN109327394A publication Critical patent/CN109327394A/en
Application granted granted Critical
Publication of CN109327394B publication Critical patent/CN109327394B/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
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0806Configuration setting for initial configuration or provisioning, e.g. plug-and-play
    • H04L41/0809Plug-and-play configuration

Landscapes

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

Abstract

The present invention provides a kind of message forwarding method and device, the described method includes: when receiving the first message that first terminal is sent from first interface, and when not inquiring matched non-default routing according to the purpose internet protocol address of first message, user's mapping table is inquired according to the purpose IP address of first message;When inquiring matched first user mapping item, according to the mac address information and interface message recorded in the first user mapping item, first message is forwarded to second terminal by the second interface that the interface message indicates.The mutual access between the terminal device accessed by the interface of the enabled plug and play gateway function of same gateway may be implemented using the embodiment of the present invention.

Description

A kind of message forwarding method and device
Technical field
The present invention relates to network communication technology field more particularly to a kind of message forwarding methods and device.
Background technique
Under some public environment, such as market, hotel etc., it is understood that there may be the various terminal devices temporarily accessed.It is different On terminal device IP (Internet Protocol, Internet protocol) configuration and it is different.If terminal equipment configuration is Static ip address, and the IP address and the gateway of access belong to different segment, then not can be carried out normal online, need to be used by terminal Family is revised as DHCP (agreement is arranged in Dynamic Host Configuration Protocol, DynamicHost) and is automatically configured, or Person inquires the suitable IP configuration of administrator, experiences poor.
Plug and play gateway function is mainly used for the difference of shield terminal IP address of equipment and gateway local network segment address It is different, to realize that terminal device in the case where not changing existing IP configuration, can connect outer net by gateway.
After opening plug and play gateway function in gateway, although the IP address of terminal device and gateway interface Not in same network segment, gateway receives ARP (Address Resolution Protocol, the address of terminal device transmission for location Analysis protocol) request after, still can be with MAC (Media Access Control, media access control) address response of gateway The ARP request.When gateway receives the message of terminal device transmission, one and gateway interface IP can be distributed for terminal device The agent IP address of address same network segment, and the source IP address in message is substituted for agent IP address.Gateway receives purpose After the response message of equipment, the purpose IP address in message can be replaced back by the agent IP address that distributes the IP of terminal device Location.This way it is secured that equipment can normally access outer net.
However practice is found, in current plug and play gateway function implementation, when two terminal devices (are assumed to be end End equipment A and terminal device B) accessing gateway equipment enabled plug and play gateway function interface, then when terminal device A send out When giving the message arrival gateway of terminal device B (or terminal device B is sent to terminal device A), gateway be will be unable to Matched non-default routing is inquired according to the message, in turn, gateway can be according to default route (if gateway is configured with Default route) message is forwarded to outer net or directly abandons the message (if default route is not configured in gateway), that is, pass through It can not mutually be accessed between the terminal device of the interface access for enabling plug and play gateway function of same gateway.
Summary of the invention
In view of this, the present invention provides a kind of message forwarding method and device, to solve existing plug and play gateway function What can not mutually be accessed between terminal device in implementation by the interface access for enabling plug and play gateway function asks Topic.
In a first aspect, the present invention provides a kind of message forwarding method, it is applied to gateway, the gateway is at least One interface is enabled plug and play gateway function, which comprises
It is interconnected when the first message for receiving first terminal transmission from first interface, and according to the purpose of first message When fidonetFido IP address does not inquire matched non-default routing, user is inquired according to the purpose IP address of first message and is reflected Firing table;
When inquiring matched first user mapping item, according to the MAC recorded in the first user mapping item Address information and interface message, the second interface indicated by the interface message forward first report to second terminal Text;
Wherein, the first kind routing is non-default routing, and user's mapping table record has second terminal equipment IP address, MAC Address and the interface message of access, the second terminal equipment are the second interface by the gateway The terminal device of access, the first interface, the interface that second interface is any enabled plug and play gateway function.
With reference to first aspect, in the first possible implementation, the destination IP according to first message Location is inquired after user's mapping table, further includes:
When not inquiring matched first user mapping item, the interface by enabling plug and play gateway function is sent First Address Resolution Protocol ARP probe messages;Wherein, the purpose IP address of first ARP probe packet is first report The purpose IP address of text;
When from third interface to the first ARP message, corresponding user is generated according to the first ARP message and is mapped List item, user's mapping item record the source IP address, source MAC and the third interface for having the first ARP message Information;Wherein, the third interface is the interface of any enabled plug and play gateway function, the source of the first ARP message IP address is the purpose IP address of first message.
The possible implementation of with reference to first aspect the first, in the second possible implementation, the gateway Equipment record has the time for sending ARP probe packet;
The interface by enabling plug and play gateway function is sent before the first ARP probe packet, further includes:
Inquire the last time for sending the first ARP probe packet of self record;
If the difference between current time and the last time for sending the first ARP probe packet is more than or equal to pre- If time threshold, then the first ARP probe packet is sent by enabling the interface of plug and play gateway function;
Otherwise, refuse to send the first ARP probe packet by the interface for enabling plug and play gateway function.
With reference to first aspect, in the third possible implementation, also record has pre- bidding in user's mapping table Know, IP address of the default mark for showing to record in corresponding user's mapping item is for IP address of internal network or outer net IP Location;
The method also includes:
When receiving the second message from outer network interface, the user is inquired according to the source IP address of second message and is reflected Firing table;
Matched second user mapping item if it exists, and the default mark recorded in the second user mapping item refers to The source IP address for showing second message is IP address of internal network, the then default mark that will be recorded in the second user mapping item The source IP address for being updated to indicate second message is the mark of outer net IP address.
The third possible implementation with reference to first aspect, in the fourth possible implementation, the basis The mac address information and interface message recorded in the first user mapping item, indicated by the interface message Two interfaces are forwarded to second terminal before first message, further includes:
The destination IP of first message is determined according to the default mark recorded in the first user mapping item Address is IP address of internal network or outer net IP address;
If IP address of internal network, then according to the mac address information and interface recorded in the first user mapping item Information forwards first message to second terminal by the second interface that the interface message indicates;
If outer net IP address, then when inquiring default route, according to the default route to first message into Row forwarding.
Second aspect, the present invention provide a kind of apparatus for forwarding message, are applied to gateway, the gateway is at least One interface is enabled plug and play gateway function, and described device includes:
Receiving unit, for receiving message;
The purpose internet protocol address of query unit, the message for being received according to the receiving unit inquires road By table;
The query unit is also used to when receive that first terminal is sent from first interface according to the receiving unit the When the purpose IP address of one message does not inquire the routing of the matched first kind, looked into according to the purpose IP address of first message Ask user's mapping table;
Transmission unit, for when the query unit inquires matched first user mapping item, according to described The MAC address information and interface message recorded in one user's mapping item, is referred to by the interface message The second interface shown forwards first message to second terminal;
Wherein, the first kind routing is non-default routing, and user's mapping table record has second terminal equipment IP address, MAC Address and the interface message of access, the second terminal equipment are the second interface by the gateway The terminal device of access, the first interface, the interface that second interface is any enabled plug and play gateway function.
In conjunction with second aspect, in the first possible implementation, the transmission unit is also used to when the cargo tracer When member does not inquire matched first user mapping item, the interface by enabling plug and play gateway function sends the first ARP Probe messages;Wherein, the purpose IP address of first ARP probe packet is the purpose IP address of first message;
Described device further include:
Generation unit is used for when the receiving unit is from third interface to the first ARP message, according to described first ARP message generates corresponding user's mapping item, user's mapping item record have the first ARP message source IP address, The information of source MAC and the third interface;Wherein, the third interface is any enabled plug and play gateway function Interface, the source IP address of the first ARP message are the purpose IP address of first message.
In conjunction with the first possible implementation of second aspect, in the second possible implementation, the gateway Equipment record has the time for sending ARP probe packet;
The query unit is also used to inquire self record when not inquiring matched first user mapping item The last time sends the time of the first ARP probe packet;
The transmission unit, if specifically for current time and it is described it is the last send the first ARP probe packet when Between between difference be more than or equal to preset time threshold, then the interface for passing through enabled plug and play gateway function sends the first ARP Probe messages;Otherwise, refuse to send the first ARP probe packet by the interface for enabling plug and play gateway function.
In conjunction with second aspect, in the third possible implementation, also record has pre- bidding in user's mapping table Know, IP address of the default mark for showing to record in corresponding user's mapping item is for IP address of internal network or outer net IP Location;
The query unit is also used to when the receiving unit receives the second message from outer network interface, according to described The source IP address of second message inquires user's mapping table;
Described device further include:
Updating unit for matched second user mapping item if it exists, and is remembered in the second user mapping item The default mark of record indicates that the source IP address of second message is IP address of internal network, then will be in the second user mapping item The default mark of record is updated to indicate that the source IP address of second message is the mark of outer net IP address.
In conjunction with the third possible implementation of second aspect, in the fourth possible implementation, described device Further include:
Determination unit, for when the query unit inquires matched first user mapping item, according to described The default mark recorded in one user's mapping item determine first message purpose IP address be IP address of internal network or Outer net IP address;
The transmission unit is specifically used for then recording according in the first user mapping item if IP address of internal network Mac address information and target interface information, the second interface indicated by the interface message forward institute to second terminal State the first message;If outer net IP address, then when inquiring default route, according to the default route to first message It is forwarded.
Using technical solution disclosed by the invention, by safeguarding user's mapping table, when from enabled plug and play gateway function First interface receive the first message of first terminal transmission, and matching is not inquired according to the purpose IP address of the first message The first kind routing when, user's mapping table is inquired according to the purpose IP address of the first message, and when inquiring matched first When user's mapping item, according to the mac address information and interface message recorded in first user's mapping item, pass through the interface The second interface of information instruction forwards first message to second terminal, to realize enabling by same gateway Mutual access between the terminal device of the interface access of plug and play gateway function.
Detailed description of the invention
Fig. 1 is a kind of flow diagram of message forwarding method provided in an embodiment of the present invention;
Fig. 2 is a kind of configuration diagram of concrete application scene provided in an embodiment of the present invention;
Fig. 3 is a kind of flow diagram of message forwarding method provided in an embodiment of the present invention;
Fig. 4 is a kind of structural schematic diagram of apparatus for forwarding message provided in an embodiment of the present invention;
Fig. 5 is the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention;
Fig. 6 is the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention;
Fig. 7 is the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention;
Fig. 8 is a kind of hardware structural diagram of apparatus for forwarding message provided in an embodiment of the present invention.
Specific embodiment
Technical solution in embodiment in order to enable those skilled in the art to better understand the present invention, and make of the invention real The above objects, features, and advantages for applying example can be more obvious and easy to understand, with reference to the accompanying drawing to technical side in the embodiment of the present invention Case is described in further detail.
It referring to Figure 1, is a kind of flow diagram of message forwarding method provided in an embodiment of the present invention, wherein the report Literary retransmission method can be applied to gateway, at least one interface of the gateway is enabled plug and play gateway function, As shown in Figure 1, the message forwarding method may comprise steps of:
It should be noted that the interface of enabled plug and play gateway function mentioned in this article refers to enabled plug and play net Close the interior network interface of function.
Step 101, when receiving the first message that first terminal is sent from first interface, and according to the purpose of the first message When IP address does not inquire the routing of the matched first kind, user's mapping table is inquired according to the purpose IP address of the first message.
In the embodiment of the present invention, first interface and the interface for being not specific to a certain fixation, but may refer in gateway The interface of any enabled plug and play gateway function;
Similarly, first terminal and it is not specific to the terminal device of a certain fixation, but may refer to any pass through first interface The terminal device of accessing gateway equipment, the embodiment of the present invention is subsequent no longer to be repeated.
In the embodiment of the present invention, in order to realize by enable plug and play gateway function interface access terminal device it Between can mutually access, gateway can safeguard one for instruct by enable plug and play gateway function interface access Terminal device between the forwarding table (referred to herein as user's mapping table) that accesses, can recorde in user's mapping table logical Cross IP address, MAC Address and the interface of the access (gateway of the terminal device of the interface access of enabled plug and play gateway function The interface of equipment) information, when gateway is inquired less than matched non-default routing (referred to herein as according to the message received First kind routing) when, message can be instructed to forward by inquiring user's mapping table.
Correspondingly, in embodiments of the present invention, when gateway receives the message that first terminal is sent from first interface When (referred to herein as the first message), gateway can inquire local routing table according to the purpose IP address of first message , to determine whether there is matched routing.
If gateway does not inquire matched first kind routing, gateway can be according to the mesh of first message IP address inquire user's mapping table.
Wherein, default route (referred to herein as Second Type routing) refers to that purpose IP address is the routing of 0.0.0.0;It is non-silent Routing is recognized for other routings in addition to default route.
Step 102, when inquiring matched first user mapping item, according to what is recorded in first user's mapping item Mac address information and interface message, the second interface indicated by the interface message forward first message to second terminal.
In the embodiment of the present invention, when gateway inquires and the matched user's mapping table of the purpose IP address of the first message When item (referred to herein as first user's mapping item), gateway can be according to the MAC recorded in first user's mapping item Address information (hereinafter referred to destination-mac address information) and interface message (hereinafter referred to target interface information), pass through Target interface information instruction interface (referred to herein as second interface) to MAC Address be destination-mac address terminal device (this Referred to herein as second terminal) forward first message.
Wherein, the mac address information recorded in user's mapping item is that the IP address recorded in user's mapping item corresponds to MAC Address (i.e. using the MAC Address of the equipment of the IP address), the interface message recorded in user's mapping item sets for gateway Standby upper access uses information (such as interface mark of the interface (interface of enabled plug and play gateway function) of the equipment of the IP address Knowledge, interface name etc.).
It should be noted that in embodiments of the present invention, first interface and second interface can be same interface, can also be with For distinct interface.
For example, user's mapping tableau format can be as shown in table 1:
Table 1
Terminal IP Terminal MAC Interface
IP1 MAC1 Interface 1
IP2 MAC2 Interface 2
It is recorded assuming that gateway is inquired with the matched first user mapping item of the purpose IP address of the first message Mac address information be MAC2, target interface information be interface 2, then gateway can be according to MAC2 encapsulated message, and passes through Interface 2 forwards.
It should be noted that in embodiments of the present invention, the information recorded in user's mapping table is not limited to above- mentioned information, For example, user's mapping table can also record terminal device agent IP address (i.e. gateway be by enable plug and play function The IP address of the terminal device distribution of the interface access of energy) etc..
In addition, in embodiments of the present invention, if not deposited in the matched first user mapping item that gateway inquires In MAC Address and interface message, then gateway can determine that first user's mapping item is inactive users mapping item, this When, gateway can be routed according to Second Type (i.e. default route) request for information determine according to default route to this first Message is forwarded and (inquires default route) or abandons the first message (not inquiring default route), and specific implementation can be joined See the associated description being forwarded in the prior art according to default route to message, this will not be repeated here for the embodiment of the present invention.
As it can be seen that in method flow shown in Fig. 1, by safeguarding user's mapping table, when gateway is from enabled plug and play The interface of gateway function is to message, can according to the destination IP of message and when not inquiring matched non-default routing User's mapping table is inquired in location, and when inquiring matched user's mapping item, according to the MAC recorded in user's mapping item Address and interface message are forwarded the message, realize and enable plug and play gateway function by same gateway Interface access terminal device between interaction.
Optionally, in embodiments of the present invention, it is above-mentioned according to the purpose IP address of the first message inquire user's mapping table it Afterwards, can also include:
When not inquiring matched first user mapping item, the interface by enabling plug and play gateway function is sent First ARP probe packet, the purpose IP address of first ARP probe packet are the purpose IP address of the first message;
When from third interface to the first ARP message, corresponding user's mapping table is generated according to the first ARP message , user's mapping item record has the information of the source IP address of the first ARP message, source MAC and third interface, should The source IP address of first ARP message is the purpose IP address of the first message.
In the embodiment of the present invention, third interface and the interface for being not specific to a certain fixation, but may refer in gateway The interface of any enabled plug and play gateway function.
Wherein, third interface and first interface can be same interface, or distinct interface;Similarly, third interface It can be same interface with second interface, or distinct interface.
In this embodiment, when gateway does not inquire matched first user according to the purpose IP address of the first message When mapping item, the purpose IP address that gateway can be sent by enabling the interface of plug and play gateway function is the first report The ARP probe packet (referred to herein as the first ARP probe packet) of the purpose IP address of text.
Wherein, when, there are when the interface of multiple enabled plug and play gateway functions, gateway can divide in gateway The first ARP probe packet is not sent by the interface of multiple enabled plug and play gateway function.
It should be noted that in embodiments of the present invention, when gateway is not looked into according to the purpose IP address of the first message When asking matched first user mapping item, gateway can be to determine according to whether inquiring default route according to default Routing is forwarded to first message and (inquires default route) or abandons the first message (not inquiring default route), tool Body realizes the associated description that may refer in the prior art be forwarded message according to default route, and the embodiment of the present invention is herein It does not repeat them here.
It in this embodiment, is the purpose IP address of the first message from third interface to source IP address when gateway ARP message (such as arp reply message or ARP request message, referred to herein as the first ARP message) when, gateway can be with Corresponding user's mapping item is generated according to the first ARP message, which records the source for having the first ARP message The information of IP address, source MAC and third interface.
Further, in this embodiment, it is contemplated that if gateway sends ARP probe packet and excessively takes place frequently, can occupy A large amount of Internet resources, and the operation of regular traffic is influenced, therefore, visited in order to avoid gateway too continually sends ARP Text is observed and predicted, for the ARP probe packet of same purpose IP address, can control its transmission time interval more than or equal to preset threshold (can be set according to actual scene, such as 2 seconds, 3 seconds).
Optionally, in one example, gateway can recorde the time for sending ARP probe packet.
For example, gateway can recorde the last send using the IP address as purpose IP for any IP address The time of the ARP probe packet of location.
Before sending the first ARP probe packet above by the interface of enabled plug and play gateway function, can also include:
Inquire the last time for sending the first ARP probe packet of self record;
If the difference between current time and the last time for sending the first ARP probe packet is more than or equal to preset time Threshold value then sends the first ARP probe packet by enabling the interface of plug and play gateway function;
Otherwise, refuse to send the first ARP probe packet by the interface for enabling plug and play gateway function.
In this example, when gateway does not inquire matched user's mapping table according to the purpose IP address of the first message Xiang Shi, gateway can inquire the last time for sending the first ARP probe packet of self record, and when judging current Between difference between time (the i.e. the last time for sending the first ARP probe packet) whether be more than or equal to preset time Threshold value.
If the difference between current time and the time is more than or equal to preset time threshold, gateway can be by making The interface of energy plug and play gateway function sends the first ARP probe packet;
If the difference between current time and the time is less than preset time threshold, gateway can be refused by making The interface of energy plug and play gateway function sends the first ARP probe packet, sends to avoid ARP probe packet excessively frequent.
It should be noted that in embodiments of the present invention, for a certain IP address, when gateway does not inquire itself note The last time for sending the ARP probe packet that purpose IP address is the IP address of record, then gateway, which can consider, works as Preceding time and gateway the last time send the difference between the time for the ARP probe packet that purpose IP address is the IP address For infinity, i.e. the difference is greater than preset time threshold.
In addition, gateway can update the hair of self record when gateway sends the first ARP probe packet again The time of the first ARP probe packet is sent, for example, the last time for sending the first ARP probe packet is updated to this time send out The time sent.
Optionally, in embodiments of the present invention, default mark can also have been recorded in above-mentioned user's mapping table, the pre- bidding Know and may be used to indicate that the IP address recorded in corresponding user's mapping item is IP address of internal network or outer net IP address;
Correspondingly, above-mentioned message forwarding method can also include:
When receiving the second message from outer network interface, the user is inquired according to the source IP address of second message and is reflected Firing table;
Matched second user mapping item if it exists, and the default mark recorded in the second user mapping item refers to The source IP address for showing the second message is IP address of internal network, then updates the default mark recorded in the second user mapping item To indicate that the source IP address of the second message is the mark of outer net IP address.
In this embodiment, in order to avoid illegal user configures public network IP address interference customer flow forwarding, user's mapping It is IP address of internal network or outer net IP address that the IP address for showing to record in corresponding user's mapping table can also be recorded in table Mark (referred to herein as default mark).
For example, it is outer net IP that this, which presets the IP address identified may include for showing to record in corresponding user's mapping table, The first identifier value of address, and IP address for showing to record in corresponding user's mapping table are the second of IP address of internal network Ident value.
Wherein, the priority of the corresponding user's mapping item of outer net IP address is higher than the corresponding user's mapping of IP address of internal network The priority of list item.
It correspondingly, can basis when gateway receives message (referred to herein as the second message) from outer network interface The source IP address of second message inquires user's mapping table.
If gateway inquires matched user's mapping item (referred to herein as second user mapping item), gateway Equipment can further obtain the default mark recorded in the second user mapping item.
If the default mark recorded in the second user mapping item indicates the source IP address of the second message for Intranet IP , that is, there is illegal user and configure public network IP address (i.e. using public network IP in location (i.e. the value of the default mark is second identifier value) IP address of the location as Intranet terminal device), then the pre- bidding that gateway can will record in the second user mapping item Know and is updated to indicate that the source IP address of second message (will record for the mark of outer net IP address in second user mapping table Default ident value is updated to first identifier value), to avoid gateway according to the second user mapping item forward the packet to Intranet.
For example, gateway inquires matched second user mapping item, and recorded in the second user mapping item Default mark value be second identifier value when, another user's mapping item can be generated in gateway, user's mapping item Middle to record the source IP address for having the second message, the value for presetting mark is first identifier value, remaining field is sky, and uses the new life At user's mapping item cover second user mapping item.
Optionally, in this embodiment, above-mentioned to be believed according to the MAC Address recorded in first user's mapping table and interface It ceases, before forwarding first message to second terminal by the second interface that the interface message indicates, can also include:
The purpose IP address that the first message is determined according to the default mark recorded in first user's mapping item is Intranet IP Address or outer net IP address;
If IP address of internal network, then according to the mac address information and interface message recorded in first user's mapping item, First message is forwarded to second terminal by the second interface that the interface message indicates;
If outer net IP address, then when inquiring default route, the first message is forwarded according to default route.
In this embodiment, when gateway is mapped according to the first user of the purpose IP address match query of the first message When list item, gateway can also further determine that the value of the default mark recorded in the first user mapping item.
If value of the default mark is second identifier value, i.e., purpose equipment is Intranet terminal device, then gateway can be with The first message is forwarded according to first user's mapping item, specific implementation may refer to related realization above, this This will not be repeated here for inventive embodiments.
If the value of the default mark is first identifier value, i.e. purpose equipment is outer net equipment, then gateway can basis Default route determination whether is inquired first message is forwarded and (inquires default route) or is abandoned according to default route First message (not inquiring default route).
In order to make those skilled in the art more fully understand technical solution provided in an embodiment of the present invention, below with reference to specific Application scenarios are illustrated technical solution provided in an embodiment of the present invention.
Fig. 2 is referred to, is a kind of configuration diagram of concrete application scene provided in an embodiment of the present invention, as shown in Fig. 2, In the application scenarios, the same gateway interface (being assumed to be interface A) of terminal device A and terminal device B accessing gateway equipment should Gateway interface enables plug and play gateway function.
Where it is assumed that the IP address of gateway is 10.0.0.1;The IP address of terminal device A is 192.168.1.2, MAC Address is 1-1-1;The IP address of terminal device B is 192.168.111.2, MAC Address 1-1-2;Gateway is terminal The agent IP address of equipment A and terminal device B distribution is respectively 10.0.0.2 and 10.0.0.3.
As shown in figure 3, based on application scenarios shown in Fig. 2, message forwarding method implementation process provided in an embodiment of the present invention It is as follows:
When terminal device A needs to access terminal device B, terminal device A can send purpose IP address to gateway For the message of 192.168.111.2.
When gateway receives the message from interface A, can according to the purpose IP address table of query and routing of the message, with Determine whether there is matched non-default routing.
Assuming that gateway does not inquire matched non-default routing, at this point, gateway can be according to the mesh of the message IP address inquire user's mapping table.
Assuming that gateway does not inquire matched user's mapping item, then on the one hand, gateway can be according to default The request for information of routing is determined to being forwarded to the message according to default route and (inquire default route) or abandon the message (not inquiring default route).
On the other hand, it is 0.0.0.0, purpose IP address 192.168.111.2 that gateway, which can send source IP address, The ARP probe packet of (i.e. the purpose IP address of the message), and generate list item as shown in Table 2:
Table 2
Agent IP Terminal IP Terminal MAC Interface
-- 192.168.111.2 -- --
It should be noted that can also record the last purpose IP address that sends in user's mapping table is corresponding user The time of the ARP probe packet of the IP address recorded in mapping item, specific implementation may refer to associated description above, This will not be repeated here for the embodiment of the present invention.
In this embodiment, there was only terminal IP in table 2 is virtual value, other are invalid value.Subsequent gateway according to The purpose IP address of message inquires user's mapping item, will not be forwarded according to user's mapping item.
When gateway receives the arp reply message or other ARP message (such as ARP request reports of terminal device B transmission Text) when, gateway inquires matched user's mapping item (i.e. user's mapping table shown in table 2 according to its source IP address ), at this point, user's mapping item as shown in table 3 can be generated in gateway:
Table 3
Agent IP Terminal IP Terminal MAC Interface
10.0.0.3 192.168.111.2 1-1-2 Interface A
When the purpose IP address that gateway receives terminal device A transmission again is the message of 192.168.111.2, Gateway can inquire user's mapping item shown in table 3, and by the purpose MAC of message according to user's mapping item 1-1-2 is revised as in location, and is forwarded by interface A, to realize access of the terminal device A to terminal device B.
Wherein, terminal device B is similar therewith to the realization of the access of terminal device A, and the embodiment of the present invention is not done superfluous herein It states.
Further, in this embodiment, illegal user configures public network IP address interference customer flow forwarding in order to prevent, Can increase whether outer net IP is identified in original user's mapping table, correspondingly, user maps tableau format can be such as chart 4 It is shown:
Table 4
Agent IP Terminal IP Terminal MAC Interface Whether outer net IP
10.0.0.2 192.168.1.2 1-1-1 Interface A It is no
10.0.0.3 192.168.111.2 1-1-2 Interface A It is no
-- 114.114.114.114 -- -- It is
When terminal device A accesses public network IP (by taking 114.114.114.114 as an example), subsequent meeting source IP address is 114.114.114.114 the return packet of the Agent IP (10.0.0.2) of purpose IP address terminal device A.Gateway can be with The outer net IP address in table 4 is generated according to the source IP address of the return packet.
Wherein, this whether outer net IP mark value be "Yes" user's mapping item priority be higher than record IP address It is identical, but whether outer net IP mark value be "No" user's mapping item priority;The high user's mapping item of priority The low user's mapping item of priority can be covered, the low user's mapping item of priority cannot cover the high user of priority Mapping item.
Through above description as can be seen that in technical solution provided in an embodiment of the present invention, pass through maintenance user's mapping Table, when the first message for receiving first terminal transmission from the first interface of enabled plug and play gateway function, and according to first When the purpose IP address of message does not inquire the routing of the matched first kind, user is inquired according to the purpose IP address of the first message Mapping table, and when inquiring matched first user mapping item, according to the MAC Address recorded in first user's mapping item Information and interface message, the second interface indicated by the interface message forward first message to second terminal, thus real The mutually exchanging visit between the terminal device by the interface access for enabling plug and play gateway function of same gateway is showed It asks.
Correspondingly, Fig. 4 is referred to, provides a kind of structural schematic diagram of apparatus for forwarding message for the embodiment of the present invention, wherein The device can be applied to the gateway in above method embodiment, as shown in figure 4, the apparatus for forwarding message may include:
Receiving unit 410, for receiving message;
Query unit 420, the purpose internet protocol address of the message for being received according to the receiving unit 410 Table of query and routing;
The query unit 420 is also used to when the first terminal received according to the receiving unit 410 from first interface When the purpose IP address of the first message sent does not inquire the routing of the matched first kind, according to the purpose of first message IP address inquires user's mapping table;
Transmission unit 430, for when the query unit 420 inquires matched first user mapping item, according to The MAC address information and interface message recorded in the first user mapping item, passes through the interface The second interface of information instruction forwards first message to second terminal;
Wherein, the first kind routing is non-default routing, and user's mapping table record has second terminal equipment IP address, MAC Address and the interface message of access, the second terminal equipment are the second interface by the gateway The terminal device of access, the first interface, the interface that second interface is any enabled plug and play gateway function.
In an alternative embodiment, the transmission unit 430, be also used to when the query unit 420 do not inquire it is matched When first user's mapping item, the interface by enabling plug and play gateway function sends the first ARP probe packet;Wherein, institute The purpose IP address for stating the first ARP probe packet is the purpose IP address of first message;
Such as scheme please also refer to Fig. 5 for the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention Shown in 5, on the basis of apparatus for forwarding message shown in Fig. 4, apparatus for forwarding message shown in Fig. 5 can also include:
Generation unit 440 is used for when the receiving unit 410 is from third interface to the first ARP message, according to institute It states the first ARP message and generates corresponding user's mapping item, which records the source IP for having the first ARP message Address, source MAC and the third interface information;Wherein, the third interface is any enabled plug and play gateway The interface of function, the source IP address of the first ARP message are the purpose IP address of first message.
In an alternative embodiment, the gateway record has the time for sending ARP probe packet;
The query unit 420 is also used to when not inquiring matched first user mapping item, inquires self record The last time for sending the first ARP probe packet;
The transmission unit 430, if specifically for the first ARP probe packet of current time and the last transmission Difference between time is more than or equal to preset time threshold, then executes the interface by enabling plug and play gateway function and send out The step of sending the first ARP probe packet;Otherwise, refuse to send the first ARP spy by the interface for enabling plug and play gateway function Observe and predict text.
In an alternative embodiment, also record has default mark in user's mapping table, and the default mark is for showing The IP address recorded in corresponding user's mapping item is IP address of internal network or outer net IP address;
The query unit 420 is also used to when the receiving unit 410 receives the second message from outer network interface, root User's mapping table is inquired according to the source IP address of second message;
Such as scheme please also refer to Fig. 6 for the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention Shown in 6, on the basis of apparatus for forwarding message shown in Fig. 4, apparatus for forwarding message shown in Fig. 6 can also include:
Updating unit 450, for matched second user mapping item if it exists, and in the second user mapping item The default mark of record indicates that the source IP address of second message is IP address of internal network, then by the second user mapping item The default mark of middle record is updated to indicate that the source IP address of second message is the mark of outer net IP address.
Such as scheme please also refer to Fig. 7 for the structural schematic diagram of another apparatus for forwarding message provided in an embodiment of the present invention Shown in 7, on the basis of apparatus for forwarding message shown in Fig. 6, apparatus for forwarding message shown in Fig. 7 can also include:
Determination unit 460, for when the query unit 420 inquires matched first user mapping item, according to The default mark recorded in the first user mapping item determines that the purpose IP address of first message is Intranet IP Address or outer net IP address;
The transmission unit 430 is specifically used for then remembering according in the first user mapping item if IP address of internal network The mac address information and target interface information of record are forwarded by the second interface that the interface message indicates to second terminal First message;If outer net IP address, then when inquiring default route, according to the default route to first report Text is forwarded.
Fig. 8 is referred to, is a kind of hardware structural diagram of apparatus for forwarding message provided in an embodiment of the present invention.The message Retransmission unit may include processor 801, the machine readable storage medium 802 for being stored with machine-executable instruction.Processor 801 It can be communicated via system bus 803 with machine readable storage medium 802.Also, by reading and executing machine readable storage Jie Above-described message forwarding side can be performed in machine-executable instruction corresponding with message forwarding logic in matter 802, processor 801 Method.
Machine readable storage medium 802 referred to herein can be any electronics, magnetism, optics or other physical stores Device may include or store information, such as executable instruction, data, etc..For example, machine readable storage medium can be easily Lose memory, nonvolatile memory or similar storage medium.Specifically, machine readable storage medium 802 can be RAM (Radom Access Memory, random access memory), flash memory, memory driver (such as hard disk drive), solid state hard disk, Any kind of storage dish (such as CD, DVD) perhaps similar storage medium or their combination.
The embodiment of the invention also provides a kind of machine readable storage mediums including machine-executable instruction, such as Fig. 8 In machine readable storage medium 802, the machine-executable instruction can by the processor 801 in apparatus for forwarding message execute with Realize message forwarding method described above.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus Realization process, details are not described herein.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit The unit of explanation may or may not be physically separated, and component shown as a unit can be or can also be with It is not physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to actual The purpose for needing to select some or all of the modules therein to realize the present invention program.Those of ordinary skill in the art are not paying Out in the case where creative work, it can understand and implement.
As seen from the above-described embodiment, it by safeguarding user's mapping table, is connect when from the first of enabled plug and play gateway function Mouth receives the first message of first terminal transmission, and does not inquire the matched first kind according to the purpose IP address of the first message When type routes, user's mapping table is inquired according to the purpose IP address of the first message, and map when inquiring matched first user When list item, according to the mac address information and interface message recorded in first user's mapping item, indicated by the interface message Second interface forward first message to second terminal, plug and play is enabled by same gateway to realize Mutual access between the terminal device of the interface access of gateway function.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to of the invention its Its embodiment.This application is intended to cover any variations, uses, or adaptations of the invention, these modifications, purposes or Person's adaptive change follows general principle of the invention and including the undocumented common knowledge in the art of the present invention Or conventional techniques.The description and examples are only to be considered as illustrative, and true scope and spirit of the invention are by following Claim is pointed out.
It should be understood that the present invention is not limited to the precise structure already described above and shown in the accompanying drawings, and And various modifications and changes may be made without departing from the scope thereof.The scope of the present invention is limited only by the attached claims.

Claims (10)

1. a kind of message forwarding method is applied to gateway, which is characterized in that at least one interface of the gateway makes There can be plug and play gateway function, which comprises
When the first message for receiving first terminal transmission from first interface, and according to the purpose internet protocol of first message When view IP address does not inquire the routing of the matched first kind, user's mapping is inquired according to the purpose IP address of first message Table;
When inquiring matched first user mapping item, according to the media interviews recorded in the first user mapping item Mac address information and interface message are controlled, the second interface indicated by the interface message is to described in second terminal forwarding First message;
Wherein, the first kind routing is non-default routing, and user's mapping table record is with having the IP of second terminal equipment The interface message of location, MAC Address and access, the second terminal equipment are to be accessed by the second interface of the gateway Terminal device, the first interface, second interface be any enabled plug and play gateway function interface.
2. the method according to claim 1, wherein described inquire according to the purpose IP address of first message After user's mapping table, further includes:
When not inquiring matched first user mapping item, the interface by enabling plug and play gateway function sends first Address Resolution Protocol ARP probe messages;Wherein, the purpose IP address of first ARP probe packet is first message Purpose IP address;
When from third interface to the first ARP message, corresponding user's mapping table is generated according to the first ARP message , which records the source IP address for having the first ARP message, source MAC and the third interface Information;Wherein, the third interface is the interface of any enabled plug and play gateway function, the source IP of the first ARP message Address is the purpose IP address of first message.
3. according to the method described in claim 2, it is characterized in that, gateway record, which has, sends ARP probe packet Time;
The interface by enabling plug and play gateway function is sent before the first ARP probe packet, further includes:
Inquire the last time for sending the first ARP probe packet of self record;
If the difference between current time and the last time for sending the first ARP probe packet is more than or equal to default Between threshold value, then the interface for passing through enabled plug and play gateway function sends the first ARP probe packet;
Otherwise, refuse to send the first ARP probe packet by the interface for enabling plug and play gateway function.
4. the method according to claim 1, wherein also record has default mark, institute in user's mapping table Stating IP address of the default mark for showing to record in corresponding user's mapping item is IP address of internal network or outer net IP address;
The method also includes:
When receiving the second message from outer network interface, the user is inquired according to the source IP address of second message and is mapped Table;
Matched second user mapping item if it exists, and the default mark instruction institute recorded in the second user mapping item The source IP address for stating the second message is IP address of internal network, then updates the default mark recorded in the second user mapping item To indicate that the source IP address of second message is the mark of outer net IP address.
5. according to the method described in claim 4, it is characterized in that, described according to recording in the first user mapping item Mac address information and interface message forward described first to second terminal by the second interface that the interface message indicates Before message, further includes:
The purpose IP address of first message is determined according to the default mark recorded in the first user mapping item For IP address of internal network or outer net IP address;
If IP address of internal network, then according to the mac address information and interface message recorded in the first user mapping item, First message is forwarded to second terminal by the second interface that the interface message indicates;
If outer net IP address, then when inquiring default route, first message is turned according to the default route Hair.
6. a kind of apparatus for forwarding message is applied to gateway, which is characterized in that at least one interface of the gateway makes There can be plug and play gateway function, described device includes:
Receiving unit, for receiving message;
Query unit, the purpose internet protocol address query routing of the message for being received according to the receiving unit Table;
The query unit is also used to when the first report for receiving first terminal transmission from first interface according to the receiving unit When the purpose IP address of text does not inquire the routing of the matched first kind, is inquired and used according to the purpose IP address of first message Family mapping table;
Transmission unit, for being used according to described first when the query unit inquires matched first user mapping item The MAC address information and interface message recorded in the mapping item of family, is indicated by the interface message Second interface forwards first message to second terminal;
Wherein, the first kind routing is non-default routing, and user's mapping table record is with having the IP of second terminal equipment The interface message of location, MAC Address and access, the second terminal equipment are to be accessed by the second interface of the gateway Terminal device, the first interface, second interface be any enabled plug and play gateway function interface.
7. device according to claim 6, which is characterized in that
The transmission unit is also used to when the query unit does not inquire matched first user mapping item, by making The interface of energy plug and play gateway function sends the first ARP probe packet;Wherein, the destination IP of first ARP probe packet Address is the purpose IP address of first message;
Described device further include:
Generation unit is used for when the receiving unit is from third interface to the first ARP message, according to the first ARP Message generates corresponding user's mapping item, which records source IP address, the source for having the first ARP message The information of MAC Address and the third interface;Wherein, the third interface is connecing for any enabled plug and play gateway function Mouthful, the source IP address of the first ARP message is the purpose IP address of first message.
8. device according to claim 7, which is characterized in that the gateway record, which has, sends ARP probe packet Time;
The query unit is also used to inquire the nearest of self record when not inquiring matched first user mapping item The primary time for sending the first ARP probe packet;
The transmission unit, if specifically for current time and the last time for sending the first ARP probe packet it Between difference be more than or equal to preset time threshold, then the interface for passing through enabled plug and play gateway function sends the first ARP detection Message;Otherwise, refuse to send the first ARP probe packet by the interface for enabling plug and play gateway function.
9. device according to claim 6, which is characterized in that also record has default mark, institute in user's mapping table Stating IP address of the default mark for showing to record in corresponding user's mapping item is IP address of internal network or outer net IP address;
The query unit is also used to when the receiving unit receives the second message from outer network interface, according to described second The source IP address of message inquires user's mapping table;
Described device further include:
Updating unit, for matched second user mapping item if it exists, and recorded in the second user mapping item Default mark indicates that the source IP address of second message is IP address of internal network, then will record in the second user mapping item Default mark be updated to indicate that the source IP address of second message is the mark of outer net IP address.
10. device according to claim 9, which is characterized in that described device further include:
Determination unit, for being used according to described first when the query unit inquires matched first user mapping item The default mark recorded in the mapping item of family determines that the purpose IP address of first message is IP address of internal network or outer net IP address;
The transmission unit is specifically used for if IP address of internal network, then according to the MAC recorded in the first user mapping item Address information and target interface information forward described first to second terminal by the second interface that the interface message indicates Message;If outer net IP address, then when inquiring default route, first message is turned according to the default route Hair.
CN201811435603.9A 2018-11-28 2018-11-28 A kind of message forwarding method and device Active CN109327394B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811435603.9A CN109327394B (en) 2018-11-28 2018-11-28 A kind of message forwarding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811435603.9A CN109327394B (en) 2018-11-28 2018-11-28 A kind of message forwarding method and device

Publications (2)

Publication Number Publication Date
CN109327394A CN109327394A (en) 2019-02-12
CN109327394B true CN109327394B (en) 2019-09-06

Family

ID=65259388

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811435603.9A Active CN109327394B (en) 2018-11-28 2018-11-28 A kind of message forwarding method and device

Country Status (1)

Country Link
CN (1) CN109327394B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109743256B (en) * 2019-03-22 2022-01-14 成都西加云杉科技有限公司 Message forwarding method and device

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101127695B (en) * 2006-08-17 2011-08-24 中兴通讯股份有限公司 A processing method for reducing invalid transmission of network traffic
US9143493B2 (en) * 2007-12-20 2015-09-22 The Directv Group, Inc. Method and apparatus for communicating between a user device and a gateway device to form a system to allow a partner service to be provided to the user device
CN101908982A (en) * 2009-06-05 2010-12-08 华为技术有限公司 Detection method, device and system of VLAN (Virtual Local Area Network)
US8619779B2 (en) * 2009-09-30 2013-12-31 Alcatel Lucent Scalable architecture for enterprise extension in a cloud topology
CN101888338B (en) * 2010-07-01 2016-06-22 中兴通讯股份有限公司 information forwarding method and gateway
CN102325077B (en) * 2011-05-25 2015-02-04 杭州华三通信技术有限公司 Communication method among branches and egress routers of branches
CN103036788A (en) * 2012-12-14 2013-04-10 上海斐讯数据通信技术有限公司 Implementation method of multi-interface gateway equipment data transmitting
US9913198B2 (en) * 2014-09-10 2018-03-06 Comcast Cable Communications, Llc Systems and methods for routing data
CN104283783B (en) * 2014-10-11 2017-09-15 新华三技术有限公司 The method and apparatus that gateway device E-Packets in a kind of plug and play network
CN105939267B (en) * 2015-10-09 2019-04-09 杭州迪普科技股份有限公司 Outband management method and device

Also Published As

Publication number Publication date
CN109327394A (en) 2019-02-12

Similar Documents

Publication Publication Date Title
US10673815B2 (en) DNS-enabled communication between heterogeneous devices
US11265368B2 (en) Load balancing method, apparatus, and system
CN113596184B (en) Hybrid cloud system, gatekeeper, network access method and storage medium
EP3391627B1 (en) Shared multi-tenant domain name system (dns) server for virtual networks and corresponding method
CN101465889B (en) Network address translation equipment and request method of response address analysis protocol
US9992086B1 (en) External health checking of virtual private cloud network environments
CN105704036B (en) Message forwarding method, device and system
US9246874B2 (en) Virtual domain name system
US7779082B2 (en) Address management device
CN104737507A (en) Ensuring any-to-any reachability with opportunistic layer 3 forwarding in massive scale data center environments
CN114095430B (en) Access message processing method, system and working node
JP2008154066A (en) Repeater, communication method, and communication program
US9973378B2 (en) Implementing gateway redundancy in a network
CN111447304B (en) Anycast node IP address enumeration method and system for anycast recursive domain name system
CN104618243A (en) Routing method, device and system, and gateway scheduling method and device
CN103873826A (en) Media stream sending control method and device
JP2010531602A (en) Method and apparatus for communication of diagnostic data in a real-time communication network
CN106464745A (en) Dns server, client and data synchronization method
CN111327668A (en) Network management method, device, equipment and storage medium
CN108965036A (en) Configure across public network equipment exchanging visit method, system, server and storage medium
CN104488240B (en) Session management method, address management method and relevant device
US10944714B1 (en) Multi-factor domain name resolution
CN109327394B (en) A kind of message forwarding method and device
CN114172853A (en) Flow forwarding and bare computer server configuration method and device
CN106878485B (en) Message processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: Room 101, 1st floor, No. 1 Building, No. 8 Courtyard, Yongjiabei Road, Haidian District, Beijing 100094

Patentee after: Beijing Huasan Communication Technology Co., Ltd.

Address before: Room 119, 1st floor, Building 2, Pioneer Road, Haidian District, Beijing 100085

Patentee before: Beijing Huasan Communication Technology Co., Ltd.