interface.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. <COMMAND name="show interfaces"
  9. help="Interface status and configuration">
  10. <ACTION>ip addr show</ACTION>
  11. </COMMAND>
  12. <COMMAND name="show ip interface"
  13. help="IP interface status and configuration">
  14. <ACTION>ip addr show</ACTION>
  15. </COMMAND>
  16. </VIEW>
  17. <VIEW name="configure-view">
  18. <COMMAND name="interface"
  19. help="Select an interface to configure"/>
  20. <COMMAND name="interface ethernet"
  21. help="Ethernet IEEE 802.3"
  22. view="configure-if-view"
  23. viewid="iface=eth${iface_num}">
  24. <PARAM name="iface_num"
  25. help="Ethernet interface number"
  26. ptype="IFACE_NUM"/>
  27. <CONFIG priority="0x2001" pattern="^${__line}$"/>
  28. </COMMAND>
  29. </VIEW>
  30. <VIEW name="configure-if-view"
  31. prompt="${SYSTEM_NAME}(config-if-${iface})# "
  32. depth="1">
  33. <!------ Inheritance ------>
  34. <NAMESPACE ref="configure-view"
  35. help="false"
  36. completion="true"/>
  37. <!------ Simple configure-if mode commands ------>
  38. <COMMAND name="exit"
  39. help="Exit from interface configuration mode">
  40. <ACTION builtin="clish_nested_up"/>
  41. </COMMAND>
  42. <COMMAND name="no"
  43. help="Negate a command or set its defaults"/>
  44. <COMMAND name="ip"
  45. help="Interface Internet Protocol config commands"/>
  46. <COMMAND name="no ip"
  47. help="Interface Internet Protocol config commands"/>
  48. <!------ IP address ------>
  49. <COMMAND name="ip address"
  50. help="Set the IP address of an interface">
  51. <PARAM name="ip_method"
  52. help="Method to get IP"
  53. ptype="SUBCOMMAND"
  54. mode="switch">
  55. <PARAM name="dhcp"
  56. help="IP Address negotiated via DHCP"
  57. ptype="SUBCOMMAND"
  58. mode="subcommand"/>
  59. <PARAM name="ip"
  60. help="IP address"
  61. ptype="IP_ADDR_MASK"/>
  62. </PARAM>
  63. <CONFIG/>
  64. <ACTION>
  65. if test "${ip_method}" = "dhcp"; then
  66. dhclient ${iface}
  67. elif test "${ip_method}" = "ip"; then
  68. ip addr show dev ${iface} | grep "inet " | (while read a b c; do ip addr del $b dev ${iface}; done)
  69. ip addr add ${ip} dev ${iface}
  70. fi
  71. </ACTION>
  72. </COMMAND>
  73. <COMMAND name="no ip address"
  74. help="Set the IP address of an interface">
  75. <CONFIG operation="unset" pattern="^ip address"/>
  76. <ACTION>
  77. ip addr show dev ${iface} | grep "inet " | (while read a b c; do ip addr del $b dev ${iface}; done)
  78. </ACTION>
  79. </COMMAND>
  80. <!------ Enable/Disable ------>
  81. <COMMAND name="disable"
  82. help="Disable the selected interface">
  83. <CONFIG operation="unset" pattern="^enable"/>
  84. <ACTION>
  85. ip link set ${iface} down
  86. </ACTION>
  87. </COMMAND>
  88. <COMMAND name="enable"
  89. help="Enable the selected interface">
  90. <CONFIG/>
  91. <ACTION>
  92. ip link set ${iface} up
  93. </ACTION>
  94. </COMMAND>
  95. </VIEW>
  96. </CLISH_MODULE>