interface.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. lock="false">
  41. <ACTION builtin="clish_nested_up"/>
  42. </COMMAND>
  43. <COMMAND name="no"
  44. help="Negate a command or set its defaults"/>
  45. <COMMAND name="ip"
  46. help="Interface Internet Protocol config commands"/>
  47. <COMMAND name="no ip"
  48. help="Interface Internet Protocol config commands"/>
  49. <!-- IP address -->
  50. <COMMAND name="ip address"
  51. help="Set the IP address of an interface">
  52. <PARAM name="ip_method"
  53. help="Method to get IP"
  54. ptype="SUBCOMMAND"
  55. mode="switch">
  56. <PARAM name="dhcp"
  57. help="IP Address negotiated via DHCP"
  58. ptype="SUBCOMMAND"
  59. mode="subcommand"/>
  60. <PARAM name="ip"
  61. help="IP address"
  62. ptype="IP_ADDR_MASK"/>
  63. </PARAM>
  64. <CONFIG/>
  65. <ACTION>
  66. if test "${ip_method}" = "dhcp"; then
  67. dhclient ${iface}
  68. elif test "${ip_method}" = "ip"; then
  69. ip addr show dev ${iface} | grep "inet " | (while read a b c; do ip addr del $b dev ${iface}; done)
  70. ip addr add ${ip} dev ${iface}
  71. fi
  72. </ACTION>
  73. </COMMAND>
  74. <COMMAND name="no ip address"
  75. help="Set the IP address of an interface">
  76. <CONFIG operation="unset" pattern="^ip address"/>
  77. <ACTION>
  78. ip addr show dev ${iface} | grep "inet " | (while read a b c; do ip addr del $b dev ${iface}; done)
  79. </ACTION>
  80. </COMMAND>
  81. <!-- Enable/Disable -->
  82. <COMMAND name="disable"
  83. help="Disable the selected interface">
  84. <CONFIG operation="unset" pattern="^enable"/>
  85. <ACTION>
  86. ip link set ${iface} down
  87. </ACTION>
  88. </COMMAND>
  89. <COMMAND name="enable"
  90. help="Enable the selected interface">
  91. <CONFIG/>
  92. <ACTION>
  93. ip link set ${iface} up
  94. </ACTION>
  95. </COMMAND>
  96. </VIEW>
  97. </CLISH_MODULE>