Summary of the invention
The object of the invention is to overcome above-mentioned shortcoming of the prior art, the class of business that a kind of source IP address by service message is determined belonging to this service message is provided, and choice for use corresponding business routing table realizes the correct transmission of the message of this class of business, and apply easy, with low cost, range of application is comparatively widely based on the method realizing message repeating Route Selection under many default gateways condition of source IP address.
In order to realize above-mentioned object, the method realizing message repeating Route Selection under the condition of the many default gateways based on source IP address of the present invention comprises the following steps:
(1) network-termination device runs multiple business, and sets up business routing table based on described each business, and described business routing table is source IP address and this business default gateway table of comparisons of this business;
(2) source IP address of the network-termination device specified services message described in;
(3) network-termination device described in carries out tagged traffic classification to the described service message through specifying;
(4) network-termination device described in selects the business routing table of mating with described service message according to marked class of service;
(5) the business default gateway in selected business routing table is defined as the default gateway of described service message by the network-termination device described in;
(6) service message described in the network-termination device described in forwards according to determined default gateway.
Should realize in the method for message repeating Route Selection based under many default gateways condition of source IP address, the source IP address of described network-termination device specified services message, be specially: described network-termination device utilizes sendmsg instruction to send service message, and imports source IP address into service message bag.
Should realize in the method for message repeating Route Selection based under many default gateways condition of source IP address, described step (3) specifically comprises the following steps:
(31) network-termination device described in utilizes iptables instruction to determine the operation code corresponding with the described source IP address of specifying in OPADD chained list;
(32) network-termination device described in utilizes iptables instruction that determined operation code is marked on described service message.
Should realize in the method for message repeating Route Selection based under many default gateways condition of source IP address, described network-termination device selects the business routing table of mating with described service message according to marked class of service, be specially: described network-termination device determines corresponding business routing table according to the operation code that described service message marks.
Should realize in the method for message repeating Route Selection based under many default gateways condition of source IP address, described step (5) specifically comprises the following steps:
(51) network-termination device described in reads the business default gateway in the business routing table corresponding with the operation code that service message marks determined;
(52) this business default gateway is defined as the default gateway of described service message by the network-termination device described in.
The method of message repeating Route Selection is realized under have employed the condition of the many default gateways based on source IP address of this invention, because first it set up the business routing table comprising business source IP address and business default gateway contrast relationship, and before E-Packeting the source IP address of specified services message, according to the class of service of the message that this source IP address marks, and determine corresponding business routing table according to mark, and then the default gateway that this message is corresponding can be determined from this business routing table, thus be able to the class of business determining belonging to this service message by the source IP address of service message, and choice for use corresponding business routing table realizes the correct transmission of the message of this class of business, overcome in prior art, in multiple services situation, the defect of concrete default gateway cannot be matched according to object IP address longest match principle, and the method application realizing message repeating Route Selection under the condition of the many default gateways based on source IP address of the present invention is easy, with low cost, range of application is comparatively extensive.
Embodiment
In order to more clearly understand technology contents of the present invention, describe in detail especially exemplified by following examples.
Refer to shown in Fig. 1, for realizing the flow chart of steps of the method for message repeating Route Selection under the condition of the many default gateways based on source IP address of the present invention.
In one embodiment, should comprise the following steps based on the method realizing message repeating Route Selection under many default gateways condition of source IP address:
(1) network-termination device runs multiple business, and sets up business routing table based on described each business, and described business routing table is source IP address and this business default gateway table of comparisons of this business;
(2) source IP address of the network-termination device specified services message described in;
(3) network-termination device described in carries out tagged traffic classification to the described service message through specifying;
(4) network-termination device described in selects the business routing table of mating with described service message according to marked class of service;
(5) the business default gateway in selected business routing table is defined as the default gateway of described service message by the network-termination device described in;
(6) service message described in the network-termination device described in forwards according to determined default gateway.
Wherein, the source IP address of the network-termination device specified services message described in step (2), is specially: described network-termination device utilizes sendmsg instruction to send service message, and imports source IP address into service message bag.
In one more preferably execution mode, described step (3) specifically comprises the following steps:
(31) network-termination device described in utilizes iptables instruction to determine the operation code corresponding with the described source IP address of specifying in OPADD chained list;
(32) network-termination device described in utilizes iptables instruction that determined operation code is marked on described service message.
Accordingly, network-termination device described in step (4) selects the business routing table of mating with described service message according to marked class of service, be then specially: described network-termination device determines corresponding business routing table according to the operation code that described service message marks.
In the preferred execution mode of one, described step (5) specifically comprises the following steps:
(51) network-termination device described in reads the business default gateway in the business routing table corresponding with the operation code that service message marks determined;
(52) this business default gateway is defined as the default gateway of described service message by the network-termination device described in.
In an application of the invention, for TR069 and the VoIP two methods business of user terminal, it has independent subnet, different default gateway and by source IP addresss different separately.For solving the aforementioned problems in the prior, the solution that the present invention takes is, according to applied business not source IP address establishment different business routing table, the default gateway of this business is only had in each routing table, then determine that what business this service message is, which business routing table of this choice for use correctly sends this service message by the source IP address of service message, the embody rule step of the method is as follows:
I. the configuration of business routing table.TR069, VoIP configuration gets business and is correlated with behind IP address, creates business routing table, and configures the list item of this business routing table, as configured the same network segment route of this business, and the default gateway etc. of configuration this business.The establishment of business routing table solves the difficult problem that simultaneously there is multiple business subnet, multiple default gateway well.
As, the source IP of TR069 business is 172.16.16.189, and business 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 source IP of VoIP business is 172.20.20.29, and business 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 amendment of II.TR069, VoIP application program, specifies message source IP address before message sends.When these business send message, conventionally sending message is do not need to specify source IP address, if specify object IP address just can route, can send that (in prior art, message source IP address is that the route entry system that basis is chosen after route is added automatically.But illustrate above, when having two or more default gateway, conventionally carrying out separately object IP address Route Selection is to choose correct route item).
Method of the present invention directly specified the source IP address of this business before giving out a contract for a project.Concrete grammar can be replace the original sendto instruction of TR069, VoIP program with sendmsg instruction, because give out a contract for a project can import source IP address into by sendmsg instruction, and sendto instruction can not be specified, the message then sent is all source IP address before carrying out MARK mark and before route.
III. MARK tag slot separate service is beaten according to source IP operation message.Method carries out MARK mark (it is the place sending local message inherently process that mangle shows OUTPUT chain) by iptables instruction at the message that mangle shows to equal this business source IP address to source IP address in OUTPUT chain, it is the message of which business that MARK mark specifically identifies, and facilitates next step processing message in the kernel Route Selection stage.
As, the source IP of TR069 business is 172.16.16.189, and business routing table table name is 51
iptables-t mangle-A OUTPUT-s 172.16.16.189-j MARK--or-mark 0x330000
The source IP of VoIP business is 172.20.20.29, and business routing table table name is 61
iptables-t mangle-A OUTPUT-s 172.20.20.29-j MARK--or-mark 0x430000
IV. MARK value is associated with corresponding business routing table table name.Namely the corresponding relation of MARK value with corresponding business routing table table name, be configured to inside kernel and save, then, when service message arrives the kernel Route Selection stage, the routing table of this business just can be found correctly to forward by the MARK value of service message and the route table name corresponding relation of preservation.
As, the source IP of TR069 business is 172.16.16.189, and business routing table table name is 51
ip rule add fwmark 0x330000/0xffff0000 table 51
The source IP of VoIP business is 172.20.20.29, and business routing table table name is 61
ip rule add fwmark 0x430000/0xffff0000 table 61
The method of message repeating Route Selection is realized under have employed the condition of the many default gateways based on source IP address of this invention, because first it set up the business routing table comprising business source IP address and business default gateway contrast relationship, and before E-Packeting the source IP address of specified services message, according to the class of service of the message that this source IP address marks, and determine corresponding business routing table according to mark, and then the default gateway that this message is corresponding can be determined from this business routing table, thus be able to the class of business determining belonging to this service message by the source IP address of service message, and choice for use corresponding business routing table realizes the correct transmission of the message of this class of business, overcome in prior art, in multiple services situation, the defect of concrete default gateway cannot be matched according to object IP address longest match principle, and the method application realizing message repeating Route Selection under the condition of the many default gateways based on source IP address of the present invention is easy, with low cost, range of application is comparatively extensive.
In this description, the present invention is described with reference to its specific embodiment.But, still can make various amendment 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.