Summary of the invention
The objective of the invention is to have overcome above-mentioned shortcoming of the prior art; Provide a kind of source IP address to confirm the class of business under this service message through service message; And select to use the corresponding business routing table to realize the correct transmission of the message of this class of business; And use easyly, with low cost, range of application is comparatively widely based on realizing under many default gateways condition of source IP address that message transmits method of routing.
In order to realize above-mentioned purpose, of the present invention based on realizing under many default gateways condition of source IP address that message transmits method of routing and may further comprise the steps:
(1) network-termination device moves multiple business, and sets up professional routing table based on described each business, and described professional routing table is this professional source IP address and this business default gateway table of comparisons;
(2) source IP address of described network-termination device specified services message;
(3) described network-termination device carries out the tagged traffic classification to described service message through appointment;
(4) described network-termination device is according to the professional routing table that class of service is selected and described service message matees of institute's mark;
(5) described network-termination device is confirmed as the professional default gateway in the selected professional routing table default gateway of described service message;
(6) described network-termination device is transmitted described service message according to determined default gateway.
Should be based on realizing under many default gateways condition of source IP address in the message forwarding method of routing; The source IP address of described network-termination device specified services message; Be specially: described network-termination device utilizes the sendmsg instruction to send service message, and imports source IP address into the service message bag.
Should transmit in the method for routing based on realization message under many default gateways condition of source IP address, described step (3) specifically may further comprise the steps:
(31) described network-termination device utilizes the iptables instruction in the OPADD chained list, to confirm to encode with the source IP address corresponding service of described appointment;
(32) described network-termination device utilizes the iptables instruction that determined operation code is marked on described service message.
Should be based on realizing under many default gateways condition of source IP address in the message forwarding method of routing; Described network-termination device is according to the professional routing table that class of service is selected and described service message matees of institute's mark, and be specially: described network-termination device is confirmed the corresponding service routing table according to the operation code of described service message mark.
Should transmit in the method for routing based on realization message under many default gateways condition of source IP address, described step (5) specifically may further comprise the steps:
(51) described network-termination device reads the professional default gateway in the operation code corresponding service routing table definite and the service message mark;
(52) described network-termination device should the business default gateway be confirmed as the default gateway of described service message.
That has adopted this invention transmits method of routing based on realization message under many default gateways condition of source IP address; Because it at first sets up the professional routing table that comprises professional source IP address and professional default gateway contrast relationship, and before E-Packeting the source IP address of specified services message; Class of service according to the message of this source IP address mark; And confirm the corresponding service routing table according to mark; And then can from this business routing table, confirm the default gateway that this message is corresponding, thus be able to confirm the class of business under this service message through the source IP address of service message, and select to use the corresponding business routing table to realize the correct transmission of the message of this class of business; Overcome in the prior art; Under multiple services situation, can't match the defective of concrete default gateway according to purpose IP address longest match principle, and of the present invention based on realizing under many default gateways condition of source IP address that message transmits method of routing and use easy; With low cost, range of application is comparatively extensive.
Embodiment
In order more to be expressly understood technology contents of the present invention, the special following examples of lifting specify.
See also shown in Figure 1ly, be of the present invention based on realizing under many default gateways condition of source IP address that message transmits the flow chart of steps of method of routing.
In one embodiment, should transmit method of routing based on realization message under many default gateways condition of source IP address may further comprise the steps:
(1) network-termination device moves multiple business, and sets up professional routing table based on described each business, and described professional routing table is this professional source IP address and this business default gateway table of comparisons;
(2) source IP address of described network-termination device specified services message;
(3) described network-termination device carries out the tagged traffic classification to described service message through appointment;
(4) described network-termination device is according to the professional routing table that class of service is selected and described service message matees of institute's mark;
(5) described network-termination device is confirmed as the professional default gateway in the selected professional routing table default gateway of described service message;
(6) described network-termination device is transmitted described service message according to determined default gateway.
Wherein, the source IP address of the described network-termination device specified services of step (2) message is specially: described network-termination device utilizes the sendmsg instruction to send service message, and imports source IP address into the service message bag.
In a kind of more preferably execution mode, described step (3) specifically may further comprise the steps:
(31) described network-termination device utilizes the iptables instruction in the OPADD chained list, to confirm to encode with the source IP address corresponding service of described appointment;
(32) described network-termination device utilizes the iptables instruction that determined operation code is marked on described service message.
Accordingly; The described network-termination device of step (4) is according to the professional routing table that class of service is selected and described service message matees of institute's mark, and then be specially: described network-termination device is confirmed the corresponding service routing table according to the operation code of described service message mark.
In a kind of preferred execution mode, described step (5) specifically may further comprise the steps:
(51) described network-termination device reads the professional default gateway in the operation code corresponding service routing table definite and the service message mark;
(52) described network-termination device should the business default gateway be confirmed as the default gateway of described service message.
In an application of the invention, be example with TR069 and two applied business of VoIP of user terminal, it all has independent subnet, different default gateway and by different separately source IP addresss.For solving the aforementioned problems in the prior; The solution that the present invention taked is; Create the different business routing table according to the different source IP addresss of applied business; Have only this professional default gateway in each routing table, confirm that through the source IP address of service message this service message is that which professional routing table what business, this selection use come correct this service message that sends then, the concrete applying step of this method is following:
I. the configuration of professional routing table.TR069, VoIP configuration are created professional routing table, and are disposed the list item of this professional routing table, as dispose this professional same network segment route, and dispose this professional default gateway etc. after getting access to professional relevant IP address.The establishment of professional routing table has solved a difficult problem that has a plurality of professional subnets, a plurality of default gateways simultaneously well.
As, the professional source IP of TR069 is 172.16.16.189, professional routing table table name is 51
ip?route?add?172.16.0.0/16?dev?eth4.100_1?table?51
ip?route?add?default?via?172.16.1.1?dev?eth4.100_1?table?51
The professional source IP of VoIP is 172.20.20.29, and professional routing table table name is 61
ip?route?add?172.20.0.0/16?dev?eth4.200_1?table?61
ip?route?add?default?via?172.20.1.1?dev?eth4.200_1?table?61
The modification of II.TR069, VoIP application program is specified the message source IP address before message sends.When these business are sent message; Sending message according to prior art is need not specify source IP address, if specify purpose IP address just can route, can send that (the message source IP address is according to the route entry system that chooses interpolation automatically after the route in the prior art.But the front explains, when two above default gateways were arranged, carrying out purpose IP address Route Selection separately according to prior art was to choose the correct route item).
Method of the present invention was directly specified this professional source IP address before giving out a contract for a project.Concrete grammar can be with sendmsg instruction replacement TR069, the original sendto instruction of VoIP program; Can import source IP address into because give out a contract for a project through sendmsg instruction; And sendto instruction can not be specified, and the message that sends then is before carrying out the MARK sign and source IP address all arranged before the route.
III. beat MARK tag slot separate service according to source IP operation message.Method is in mangle table OUTPUT chain, the message that source IP address equals this professional source IP address to be carried out MARK mark (mangle table OUTPUT chain is to send the place that local message must pass through) through iptables instruction; It is that the MARK mark has specifically identified for which professional message, makes things convenient for next step message is handled in the kernel Route Selection stage.
As, the professional source IP of TR069 is 172.16.16.189, professional routing table table name is 51
iptables-t?mangle-A?OUTPUT-s?172.16.16.189-j?MARK--or-mark?0x330000
The professional source IP of VoIP is 172.20.20.29, and professional routing table table name is 61
iptables-t?mangle-A?OUTPUT-s?172.20.20.29-j?MARK--or-mark?0x430000
IV. associate the MARK value with corresponding professional routing table table name.Promptly the corresponding relation of MARK value with corresponding professional routing table table name; Being configured to the kernel the inside preserves; When service message arrives the kernel Route Selection stage, just can find this professional routing table correctly to transmit then through the MARK value of service message and the route table name corresponding relation of preserving.
As, the professional source IP of TR069 is 172.16.16.189, professional routing table table name is 51
ip?rule?add?fwmark?0x330000/0xffff0000?table?51
The professional source IP of VoIP is 172.20.20.29, and professional routing table table name is 61
ip?rule?add?fwmark?0x430000/0xffff0000?table?61
That has adopted this invention transmits method of routing based on realization message under many default gateways condition of source IP address; Because it at first sets up the professional routing table that comprises professional source IP address and professional default gateway contrast relationship, and before E-Packeting the source IP address of specified services message; Class of service according to the message of this source IP address mark; And confirm the corresponding service routing table according to mark; And then can from this business routing table, confirm the default gateway that this message is corresponding, thus be able to confirm the class of business under this service message through the source IP address of service message, and select to use the corresponding business routing table to realize the correct transmission of the message of this class of business; Overcome in the prior art; Under multiple services situation, can't match the defective of concrete default gateway according to purpose IP address longest match principle, and of the present invention based on realizing under many default gateways condition of source IP address that message transmits method of routing and use easy; With low cost, range of application is comparatively extensive.
In this specification, the present invention is described with reference to its certain embodiments.But, still can make various modifications and conversion obviously and not deviate from the spirit and scope of the present invention.Therefore, specification and accompanying drawing are regarded in an illustrative, rather than a restrictive.