route.xml 2.6 KB

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