route.xml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <CLISH_MODULE xmlns="http://clish.sourceforge.net/XMLSchema"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://clish.sourceforge.net/XMLSchema
  5. http://clish.sourceforge.net/XMLSchema/clish.xsd">
  6. <!--=======================================================-->
  7. <VIEW name="enable-view">
  8. <!------ Show routing information ------>
  9. <COMMAND name="show ip route"
  10. help="IP routing table">
  11. <ACTION>ip route show</ACTION>
  12. </COMMAND>
  13. </VIEW>
  14. <VIEW name="configure-view">
  15. <!------ Enable/Disable routing ------>
  16. <COMMAND name="ip routing"
  17. help="Enable IP routing">
  18. <CONFIG operation="unset" pattern="^no ip routing"/>
  19. <ACTION>
  20. echo "1" > /proc/sys/net/ipv4/ip_forward
  21. </ACTION>
  22. </COMMAND>
  23. <COMMAND name="no ip routing"
  24. help="Disable IP routing">
  25. <CONFIG priority="0x1500"/>
  26. <ACTION>
  27. echo "0" > /proc/sys/net/ipv4/ip_forward
  28. </ACTION>
  29. </COMMAND>
  30. <!------ Default gateway ------>
  31. <COMMAND name="ip default-gateway"
  32. help="Specify default gateway (if not routing IP)">
  33. <PARAM name="ip"
  34. help="IP address of default gateway"
  35. ptype="IP_ADDR"/>
  36. <CONFIG priority="0x9000" splitter="false"/>
  37. <ACTION>
  38. ip route replace to default via ${ip}
  39. </ACTION>
  40. </COMMAND>
  41. <COMMAND name="no ip default-gateway"
  42. help="Specify default gateway (if not routing IP)">
  43. <CONFIG operation="unset" pattern="^ip default-gateway"/>
  44. <ACTION>
  45. ip route delete to default
  46. </ACTION>
  47. </COMMAND>
  48. <!------ Set/Unset static route ------>
  49. <COMMAND name="ip route"
  50. help="Establish static routes">
  51. <PARAM name="ip"
  52. help="Destination prefix"
  53. ptype="IP_ADDR_MASK"/>
  54. <PARAM name="route_target"
  55. help="Route target"
  56. ptype="STRING"
  57. mode="switch">
  58. <PARAM name="ethernet"
  59. help="Ethernet IEEE 802.3"
  60. ptype="SUBCOMMAND"
  61. mode="subcommand">
  62. <PARAM name="iface_num"
  63. help="Ethernet interface number"
  64. ptype="IFACE_NUM"/>
  65. </PARAM>
  66. <PARAM name="forward"
  67. help="Forwarding router's address"
  68. ptype="IP_ADDR"/>
  69. </PARAM>
  70. <CONFIG priority="0x9002" pattern="^ip route ${ip} " splitter="false"/>
  71. <ACTION>
  72. if test "${route_target}" = "ethernet"; then
  73. ip route replace to ${ip} dev eth${iface_num}
  74. exit $?
  75. elif test "${route_target}" = "forward"; then
  76. ip route replace to ${ip} via ${forward}
  77. exit $?
  78. fi
  79. </ACTION>
  80. </COMMAND>
  81. <COMMAND name="no ip route"
  82. help="Establish static routes">
  83. <PARAM name="ip"
  84. help="Destination prefix"
  85. ptype="IP_ADDR_MASK"/>
  86. <CONFIG operation="unset" pattern="^ip route ${ip} "/>
  87. <ACTION>
  88. ip route delete to ${ip}
  89. </ACTION>
  90. </COMMAND>
  91. </VIEW>
  92. </CLISH_MODULE>