Advertisement
kyob

ubnt vlan

Aug 19th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. http://forum.ubnt.com/showthread.php?t=8654&page=2
  2.  
  3. #the link must be in WDS mode
  4. #These script can be placed into the following file and then written to memory.
  5. #
  6. ###Code:
  7. ###
  8. ###/etc/persistent/rc.poststart
  9. #
  10. #Remember if the script isn't quite correct it may brick the radio to a point
  11. #where you'll need to perform the full reset procedure. We normally run the
  12. #script manually first which will apply the changes without making them
  13. #permanent.
  14. #To commit the changes to the radio type the following and reset...
  15. #
  16. ###Code:
  17. ###
  18. ###cfgmtd -w -p /etc/
  19. ###reset
  20.  
  21. #----NS5 AP-----------
  22. #----Vlan Constants----
  23. MVLAN_ID=1
  24. VLAN1_ID=4
  25. VLAN2_ID=2
  26. #----------------------
  27. #----IP Address--------
  28. IP_ADDR=172.31.5.4
  29. NETMASK=255.255.0.0
  30. GATEWAY=172.31.31.254
  31. #----------------------
  32. #Clear out wireless interface ip address
  33. ifconfig ath0 0.0.0.0
  34. #Bring down and destroy default bridge
  35. ifconfig br0 down
  36. brctl delif br0 ath0
  37. brctl delif br0 eth0
  38. brctl delbr br0
  39. #
  40. #--------------------------------------------------------------------
  41. #Create and configure Management Vlan bridge (Allows pass-thru to SM)
  42. #--------------------------------------------------------------------
  43. #Create bridge for management vlan
  44. brctl addbr br0
  45.  
  46. #Add mvlan onto ethernet/wireless interface
  47. vconfig add eth0 ${MVLAN_ID}
  48. vconfig add ath0 ${MVLAN_ID}
  49.  
  50. #Bring up mvlanned interfaces with defaults
  51. ifconfig eth0.${MVLAN_ID} 0.0.0.0 up
  52. ifconfig ath0.${MVLAN_ID} 0.0.0.0 up
  53.  
  54. #Attach mvlanned ethernet/wireless interface to bridge
  55. brctl addif br0 eth0.${MVLAN_ID}
  56. brctl addif br0 ath0.${MVLAN_ID}
  57.  
  58. #Configure ip address for mvlanned bridge
  59. ifconfig br0 ${IP_ADDR} netmask ${NETMASK} up
  60. route del default gw 0.0.0.0
  61. route add default gw ${GATEWAY} br0
  62. #
  63. #---------------------------------------------------------------------
  64. #Create bridge to pass through customer vlans
  65. #---------------------------------------------------------------------
  66. #Create bridge for customer vlan1
  67. brctl addbr br${VLAN1_ID}
  68. #
  69. #Add vlan onto wireless/ethernet interfaces
  70. vconfig add ath0 ${VLAN1_ID}
  71. vconfig add eth0 ${VLAN1_ID}
  72. #
  73. #Bring up vlanned interfaces with defaults
  74. ifconfig ath0.${VLAN1_ID} 0.0.0.0 up
  75. ifconfig eth0.${VLAN1_ID} 0.0.0.0 up
  76. #
  77. #Attach vlanned wireless/ethernet interface to bridge
  78. brctl addif br${VLAN1_ID} ath0.${VLAN1_ID}
  79. brctl addif br${VLAN1_ID} eth0.${VLAN1_ID}
  80. #
  81. #Bring up bridge with defaults
  82. ifconfig br${VLAN1_ID} 0.0.0.0 up
  83.  
  84. #Create bridge for customer vlan2
  85. brctl addbr br${VLAN2_ID}
  86. #
  87. #Add vlan onto wireless/ethernet interfaces
  88. vconfig add ath0 ${VLAN2_ID}
  89. vconfig add eth0 ${VLAN2_ID}
  90. #
  91. #Bring up vlanned interfaces with defaults
  92. ifconfig ath0.${VLAN2_ID} 0.0.0.0 up
  93. ifconfig eth0.${VLAN2_ID} 0.0.0.0 up
  94. #
  95. #Attach vlanned wireless/ethernet interface to bridge
  96. brctl addif br${VLAN2_ID} ath0.${VLAN2_ID}
  97. brctl addif br${VLAN2_ID} eth0.${VLAN2_ID}
  98. #
  99. #Bring up bridge with defaults
  100. ifconfig br${VLAN2_ID} 0.0.0.0 up
  101.  
  102. ******************************************************
  103.  
  104. #----NS5 SM-----------
  105. #----Vlan Constants----
  106. MVLAN_ID=1
  107. VLAN1_ID=4
  108. VLAN2_ID=2
  109. #----------------------
  110. #----IP Information----
  111. IP_ADDR=172.31.5.3
  112. NETMASK=255.255.0.0
  113. GATEWAY=172.31.31.254
  114. #----------------------
  115. #Delete default gateway from device
  116. route del default gw 0.0.0.0
  117. #
  118. #Bring down and destroy default bridge
  119. ifconfig br0 0.0.0.0
  120. ifconfig br0 down
  121. brctl delif br0 ath0
  122. brctl delif br0 eth0
  123. brctl delbr br0
  124. #
  125. #---------------------------------------------------------------
  126. #Create and configure Management Vlan
  127. #---------------------------------------------------------------
  128. #Add MVlan onto wireless interface and configure ip address
  129. vconfig add ath0 ${MVLAN_ID}
  130. ifconfig ath0.${MVLAN_ID} ${IP_ADDR} netmask ${NETMASK} up
  131. route add default gw ${GATEWAY} ath0.${MVLAN_ID}
  132. #
  133. #---------------------------------------------------------------
  134. #Tag ethernet traffic as it passes to wireless interface
  135. #---------------------------------------------------------------
  136. #Create bridge for customer vlan
  137. brctl addbr br0
  138. #
  139. #Add vlan onto wireless interface
  140. vconfig add ath0 ${VLAN1_ID}
  141. vconfig add eth0 ${VLAN1_ID}
  142. #
  143. #Attach vlanned wireless/untagged ethernet interface to bridge
  144. brctl addif br0 ath0.${VLAN1_ID}
  145. brctl addif br0 eth0.${VLAN1_ID}
  146. #
  147. #Bring up interfaces with defaults
  148. ifconfig ath0.${VLAN1_ID} 0.0.0.0 up
  149. ifconfig eth0.${VLAN1_ID} 0.0.0.0 up
  150. #
  151. #Bring up bridges with defaults
  152. ifconfig br0 up
  153.  
  154. #Create bridge for customer vlan 2
  155. brctl addbr br1
  156. #
  157. #Add vlan onto wireless interface
  158. vconfig add ath0 ${VLAN2_ID}
  159. vconfig add eth0 ${VLAN2_ID}
  160. #
  161. #Attach vlanned wireless/untagged ethernet interface to bridge
  162. brctl addif br1 ath0.${VLAN2_ID}
  163. brctl addif br1 eth0.${VLAN2_ID}
  164. #
  165. #Bring up interfaces with defaults
  166. ifconfig ath0.${VLAN2_ID} 0.0.0.0 up
  167. ifconfig eth0.${VLAN2_ID} 0.0.0.0 up
  168. #
  169. #Bring up bridges with defaults
  170. ifconfig br1 up
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement