linux ¸ß¼¶Â·Óɼ°Á÷Á¿¿ØÖÆ×ܽá
×÷Õß ØýÃû¼¼Êõ
À´Ô´ Linuxϵͳ
ä¯ÀÀ
·¢²¼Ê±¼ä 2012-05-17
oute2/rt_tables
echo 300 T2 >> /etc/iproute2/rt_tables
½ÓÏÂÀ´,ʹÓÃip rule addÃüÁîÀ´´´½¨¾ßÌåµÄ±í,²¢¿ÉÒÔÔÚ±íÖÐÌí¼ÓÔ´µØÖ·»òÄ¿±êµØÖ·µÈ²ÎÊý.ÈçÏÂʵÀý,´´½¨±íT1ºÍT2.
Àý£ºroute@linux# ip rule add from 1.1.1.1 table T1
route@linux# ip rule add from 192.203.80.0/24 table T1
route@linux# ip rule add to 192.203.80.0/24 table T2
route@linux# ip rule add table T2ÉÏÊöÄÚÈݱíʾÕâЩԴµØÖ·/Ä¿µÄµØÖ·/ËùÓеØÖ·½«Ó¦ÓÃÓÚT1/T2±íÖеÄ·ÓɹæÔò.
ÔÚʹÓÃip rule add´´½¨±íʱ,¿ÉÒÔÖ¸¶¨µÄ²ÎÊýÓУºtype TYPE (default),from PREFIX,to PREFIX,iif NAME,tos TOS or dsfield TOS,fwmark MARK,priority PREFERENCE,table TABLEID,realms FROM/TO,nat ADDRESS.
,´´½¨¾ßÌåµÄ·ÓÉÌõÄ¿ÖÁÖ¸¶¨µÄ±íÖУ¨Ä¬ÈÏΪmain±í£©,ÈçÏÂËùʾ£º
route@linux# ip route add default via 192.168.0.1 dev eth0 table T1
route@linux# ip route add default via 192.168.1.1 dev eth1 table T2
ËÄ¡¢²ßÂÔ·ÓÉÅäÖÃʵÀý
ʵÑéÍØÆËÈçÏ£º
1¡¢´´½¨Á½¸ö±í,·Ö±ðΪdianxin,wangtong,±à¼Îª300ºÍ400. route@linux#echo 300 dianxin >>/etc/iproute/rt_tables route@linux# echo 400 wangtong >>/etc/iproute/rt_tables route@linux#ip rule add from $IP1 table dianxing route@linux#ip rule add from $IP2 table wangtong 2¡¢Ìí¼ÓÏà¹Ø·ÓÉÖÁÁ½¸ö±íÖÐ. 3¡¢ÊµÏÖ¸ºÔؾùºâ. ²ßÂÔ·ÓÉ×ܽ᣺ 1¡¢Ìí¼Ó·Óɱí,±àºÅÖÁϵͳÖÐ. 2¡¢Ìí¼Ó¾ßÌåµÄ·ÓÉÌõÄ¿²¢Ö¸ÏòÓû§×Ô¶¨ÒåµÄ·ÓɱíÖУ¨ÈçĬÈÏ·ÓÉ£©. 3¡¢Ìí¼Ó¾ßÌåµÄ¹æÔòÖÁ·ÓɱíÖÐ,ÈçʲôÑùµÄÔ´µØÖ·ÒÔ¼°¶ÔÓ¦µÄÓÅÏȼ¶. 4¡¢ÔÚ·ÓɱíÖÐͨ¹ýnexthop²ÎÊýʵÏÖ¸ºÔؾùºâ,»òÕß¿ÉÒÔΪÊý¾Ý´òmask,È»ºóÉèÖñê¼Ç1µÄÊý¾Ý´ÓÄĸö±í×ß,±ê¼Ç2µÄÊý¾Ý´ÓÄĸö±í. LinuxÏÂÍøͨ¡¢µçÐÅ¡¢½ÌÓý¶à³ö¿Ú²ßÂÔ·ÓÉÅäÖÃÏê½â Ò»¡¢´¦ÀíÁ÷Á¿·Ö¸îµÄÎÊÌ⣻¶þ¡¢½â¾öË«Ï߸ºÔؾùºâµÄÎÊÌâ.ÔÎÄÈçÏ£º 1¡¢Á÷Á¿·Ö¸î ÊÇÈçºÎ±£Ö¤£º»ØÓ¦À´×Ôijһ¸öISPµÄÊý¾Ý°üʱ,ÈÔȻʹÓÃÏàͬµÄISP. ÈÃÎÒÃÇÏȶ¨ÒåһЩ·ûºÅ.ÁîµÚÒ»¿éÍø¿¨µÄÃû×Ö½Ðeth1,¶øµÚ¶þ¿éÍø¿¨½Ð×öeth2£»È»ºóÉèÖÃÍø¿¨1µÄIPµØַΪ221.200.0.2£¨CNC·ÖÅäÍøÖ·£©,Íø¿¨2 µÄIPµØַΪ58.56.0.2£¨CTC·ÖÅäÍøÖ·£©£»ISP1£¨ÁªÍ¨£©Íø¹ØµØַΪ221.200.0.1,ISP2£¨µçÐÅ£©Íø¹ØµØַΪ58.56.0.1£»,ISP1£¨ÁªÍ¨£©µÄÍøÂçµØַΪ211.200.0.0/30,ISP2£¨µçÐÅ£©µÄÍøÂçµØַΪ58.56.0.0/30. ¶îÍâ´´½¨Á½¸ö·Óɱí,T1 ºÍT2 ,¼ÓÈëµ½/etc//iproute2/rt_tablesÖÐ.È»ºóÈçÏÂÉèÖÃÁ½¸ö·ÓɱíÖеÄ·ÓÉ£º ip route add 211.200.0.0/30 dev eth1 src 221.200.0.2 table T1 ip route add default via 221.200.0.1 table T1 ip route add default via 221.200.0.1 table 50 ip route add 58.56.0.0/30 dev eth2 src 58.56.0.2 table 51 ip route add default via 58.56.0.1 table 51 ûʲô¿É˵µÄ,ÓëÇ°ÃæÏàͬ,Ö»ÊǽöÓÃÊý×Ö±íʾ·Óɱí. 2¡¢Õë¶ÔÎÒÃÇÒª·ÃÎʵÄÄ¿±êµØÖ·,Ñ¡Ôñ²»Í¬µÄ·Óɱí,½øÐзÓÉ ÓдóÁ¿µÄÍøÂçµØÖ·ÐèÒªÉèÖò»Í¬µÄ¹æÔò,²ÉÓÃÃüÁîģʽ²»±ãÓÚÐÞ¸Ä,×öÁËÒ»¸ö¼òµ¥µÄ½Å±¾Îļþ,ÅäÖÃÎļþÓëqlcm²ÉÓÃÏàͬµÄ½á¹¹. ¹ØÓÚ²ßÂÔ·ÓɵÄÏêϸʹÓÃ,¿ÉÒԲο¼Êé¼®£ºPolicy Routing Using Linux |
ÁèÖڿƼ¼×¨ÒµÌṩ·þÎñÆ÷×âÓᢷþÎñÆ÷Íйܡ¢ÆóÒµÓʾ֡¢ÐéÄâÖ÷»úµÈ·þÎñ£¬¹«Ë¾ÍøÕ¾£ºhttp://www.lingzhong.cn ΪÁ˸ø¹ã´ó¿Í»§Á˽â¸ü¶àµÄ¼¼ÊõÐÅÏ¢£¬±¾¼¼ÊõÎÄÕÂÊÕ¼¯À´Ô´ÓÚÍøÂç,ÁèÖڿƼ¼×ðÖØÎÄÕÂ×÷ÕߵİæȨ£¬Èç¹ûÓÐÉæ¼°ÄãµÄ°æȨÓбØҪɾ³ýÄãµÄÎÄÕ£¬ÇëºÍÎÒÃÇÁªÏµ¡£ÒÔÉÏÐÅÏ¢ÓëÎÄÕÂÕýÎÄÊDz»¿É·Ö¸îµÄÒ»²¿·Ö,Èç¹ûÄúҪתÔر¾ÎÄÕÂ,Çë±£ÁôÒÔÉÏÐÅÏ¢£¬Ð»Ð»! |
ÉÏһƪ: ÔÚLinuxÏ»ñÈ¡È«¹ú¸÷µØIPµØÖ·¶Î·½·¨ÏÂһƪ: linuxÖ®vsftpÅäÖÃ
¹ØÓÚlinux ¸ß¼¶Â·Óɼ°Á÷Á¿¿ØÖÆ×ܽáµÄËùÓÐÆÀÂÛ