So far we have learned how Iproute works, and have mentioned netfilter many times. Here, you can just take the opportunity to see Rusty's notoriously unreliable guide. NetFilter itself can be found here.
NetFilter allows us to filter packets or tamper with the packet header. A special feature is that we can put a digital tag on the packet. You can use the--set-mark mechanism.
For example, this command marks all packets sent to 25/TCP (outgoing mail):
For example, 11545.html "> We have multiple connections, one is based on flowmeter fees, more expensive but soon, the other is a monthly, but relatively slow. Of course we'd like to send email packets to the cheaper route.
We have labeled "1" for those packets, and we now command the routing strategy database to implement this feature:
# echo 201 Mail.out >>/etc/iproute2/rt_tables # IP rule Add fwmark 1 table mail.out # IP Rule ls 0:from All lookup Local 32764:from all Fwmark 1 lookup mail.out 32766:from All lookup Main 32767:from All Lookup Default
Now we build a route to that cheap link to generate the Mail.out routing table:
#/SBIN/IP route add default via 195.96.98.253 dev ppp0 table mail.out
This is done. We may need some exceptions, and there are many ways to achieve them. We can modify the NetFilter command to exclude some hosts, or we can insert some lower priority rules to send packets to the main routing table for the excluded host.
We can also identify different service types of packets by identifying their TOS bits, and then establish rules for them separately. You can even use this method to support interactive services such as ISDN lines.
Needless to say, this, of course, can also be used on machines that are doing NAT ("camouflage").
Important Reminder: We received reports that the MASQ and SNAT functions are in conflict with the packet markings. Rusty Russell explained in this post. Turn off filtering in reverse direction to work properly.
Note: If you want to mark a packet, you need some configuration within and between:
ip:advanced Router (config_ip_advanced_router) [y/n/?] Ip:policy Routing (config_ip_multiple_tables) [y/n/?] Ip:use netfilter MARK http://www.aliyun.com/zixun/aggregation/9541.html ">value as routing key (Config_ip_route_fwmark ) [y/n/?]
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.