ahmar16

traffic-acct.sh

Apr 16th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.51 KB | None | 0 0
  1. #! /bin/sh
  2. # if FORWARD chain doesnt have the rules, add them
  3.  
  4. # Check whether chains exists
  5.  
  6. if ! iptables -nL TRAFFIC_ACCT_IN >/dev/null 2>&1
  7. then
  8. iptables -N TRAFFIC_ACCT_IN
  9. fi
  10. if ! iptables -nL TRAFFIC_ACCT_OUT >/dev/null 2>&1
  11. then
  12. iptables -N TRAFFIC_ACCT_OUT
  13. fi
  14.  
  15. iptables -C FORWARD -i pppoe-wan -j TRAFFIC_ACCT_IN
  16. if [ $? == 1 ]
  17. then
  18. {
  19. iptables -I FORWARD -i pppoe-wan -j TRAFFIC_ACCT_IN
  20. }
  21. fi
  22.  
  23. iptables -C FORWARD -o pppoe-wan -j TRAFFIC_ACCT_OUT
  24. if [ $? == 1 ]
  25. then
  26. {
  27. iptables -I FORWARD -o pppoe-wan -j TRAFFIC_ACCT_OUT
  28. }
  29. fi
  30.  
  31.  
  32. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.101 -m comment --comment "ahmar-laptop-in"
  33. if [ $? == 1 ]
  34. then
  35. {
  36. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.101 -m comment --comment "ahmar-laptop-in"
  37. }
  38. fi
  39. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.101 -m comment --comment "ahmar-laptop-out"
  40. if [ $? == 1 ]
  41. then
  42. {
  43. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.101 -m comment --comment "ahmar-laptop-out"
  44. }
  45. fi
  46.  
  47.  
  48. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.102 -m comment --comment "ahmar-mobile-in"
  49. if [ $? == 1 ]
  50. then
  51. {
  52. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.102 -m comment --comment "ahmar-mobile-in"
  53. }
  54. fi
  55. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.102 -m comment --comment "ahmar-mobile-out"
  56. if [ $? == 1 ]
  57. then
  58. {
  59. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.102 -m comment --comment "ahmar-mobile-out"
  60. }
  61. fi
  62. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.103 -m comment --comment "iqra-tab-in"
  63. if [ $? == 1 ]
  64. then
  65. {
  66. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.103 -m comment --comment "iqra-tab-in"
  67. }
  68. fi
  69. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.103 -m comment --comment "iqra-tab-out"
  70. if [ $? == 1 ]
  71. then
  72. {
  73. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.103 -m comment --comment "iqra-tab-out"
  74. }
  75. fi
  76.  
  77.  
  78. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.104 -m comment --comment "iqra-mobile-in"
  79. if [ $? == 1 ]
  80. then
  81. {
  82. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.104 -m comment --comment "iqra-mobile-in"
  83. }
  84. fi
  85. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.104 -m comment --comment "iqra-mobile-out"
  86. if [ $? == 1 ]
  87. then
  88. {
  89. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.104 -m comment --comment "iqra-mobile-out"
  90. }
  91. fi
  92.  
  93.  
  94. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.111 -m comment --comment "adnan-laptop-in"
  95. if [ $? == 1 ]
  96. then
  97. {
  98. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.111 -m comment --comment "adnan-laptop-in"
  99. }
  100. fi
  101. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.111 -m comment --comment "adnan-laptop-out"
  102. if [ $? == 1 ]
  103. then
  104. {
  105. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.111 -m comment --comment "adnan-laptop-out"
  106. }
  107. fi
  108.  
  109.  
  110. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.112 -m comment --comment "adnan-mobile-in"
  111. if [ $? == 1 ]
  112. then
  113. {
  114. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.112 -m comment --comment "adnan-mobile-in"
  115. }
  116. fi
  117. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.112 -m comment --comment "adnan-mobile-out"
  118. if [ $? == 1 ]
  119. then
  120. {
  121. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.112 -m comment --comment "adnan-mobile-out"
  122. }
  123. fi
  124.  
  125.  
  126. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.113 -m comment --comment "sunara-mobile-in"
  127. if [ $? == 1 ]
  128. then
  129. {
  130. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.113 -m comment --comment "sunara-mobile-in"
  131. }
  132. fi
  133. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.113 -m comment --comment "sunara-mobile-out"
  134. if [ $? == 1 ]
  135. then
  136. {
  137. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.113 -m comment --comment "sunara-mobile-out"
  138. }
  139. fi
  140. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.114 -m comment --comment "wasim-mobile-in"
  141. if [ $? == 1 ]
  142. then
  143. {
  144. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.114 -m comment --comment "wasim-mobile-in"
  145. }
  146. fi
  147. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.114 -m comment --comment "wasim-mobile-out"
  148. if [ $? == 1 ]
  149. then
  150. {
  151. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.114 -m comment --comment "wasim-mobile-out"
  152. }
  153. fi
  154.  
  155.  
  156. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.115 -m comment --comment "ijaz-mobile-in"
  157. if [ $? == 1 ]
  158. then
  159. {
  160. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.115 -m comment --comment "ijaz-mobile-in"
  161. }
  162. fi
  163. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.115 -m comment --comment "ijaz-mobile-out"
  164. if [ $? == 1 ]
  165. then
  166. {
  167. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.115 -m comment --comment "ijaz-mobile-out"
  168. }
  169. fi
  170.  
  171.  
  172.  
  173. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.116 -m comment --comment "shahbaz-mobile-in"
  174. if [ $? == 1 ]
  175. then
  176. {
  177. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.116 -m comment --comment "shahbaz-mobile-in"
  178. }
  179. fi
  180. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.116 -m comment --comment "shahbaz-mobile-out"
  181. if [ $? == 1 ]
  182. then
  183. {
  184. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.116 -m comment --comment "shahbaz-mobile-out"
  185. }
  186. fi
  187.  
  188.  
  189.  
  190. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.117 -m comment --comment "nomi1-mobile-in"
  191. if [ $? == 1 ]
  192. then
  193. {
  194. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.117 -m comment --comment "nomi1-mobile-in"
  195. }
  196. fi
  197. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.117 -m comment --comment "nomi1-mobile-out"
  198. if [ $? == 1 ]
  199. then
  200. {
  201. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.117 -m comment --comment "nomi1-mobile-out"
  202. }
  203. fi
  204.  
  205.  
  206.  
  207. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.118 -m comment --comment "nomi2-mobile-in"
  208. if [ $? == 1 ]
  209. then
  210. {
  211. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.118 -m comment --comment "nomi2-mobile-in"
  212. }
  213. fi
  214. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.118 -m comment --comment "nomi2-mobile-out"
  215. if [ $? == 1 ]
  216. then
  217. {
  218. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.118 -m comment --comment "nomi2-mobile-out"
  219. }
  220. fi
  221.  
  222.  
  223.  
  224. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.119 -m comment --comment "nomi-laptop-in"
  225. if [ $? == 1 ]
  226. then
  227. {
  228. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.119 -m comment --comment "nomi-laptop-in"
  229. }
  230. fi
  231. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.119 -m comment --comment "nomi-laptop-out"
  232. if [ $? == 1 ]
  233. then
  234. {
  235. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.119 -m comment --comment "nomi-laptop-out"
  236. }
  237. fi
  238.  
  239.  
  240. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.120 -m comment --comment "sami-mobile-in"
  241. if [ $? == 1 ]
  242. then
  243. {
  244. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.120 -m comment --comment "sami-mobile-in"
  245. }
  246. fi
  247. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.120 -m comment --comment "sami-mobile-out"
  248. if [ $? == 1 ]
  249. then
  250. {
  251. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.120 -m comment --comment "sami-mobile-out"
  252. }
  253. fi
  254. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.131 -m comment --comment "baloch1-device-in"
  255. if [ $? == 1 ]
  256. then
  257. {
  258. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.131 -m comment --comment "baloch1-device-in"
  259. }
  260. fi
  261. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.131 -m comment --comment "baloch1-device-out"
  262. if [ $? == 1 ]
  263. then
  264. {
  265. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.131 -m comment --comment "baloch1-device-out"
  266. }
  267. fi
  268.  
  269.  
  270. iptables -C TRAFFIC_ACCT_IN --dst 192.168.1.132 -m comment --comment "baloch2-device-in"
  271. if [ $? == 1 ]
  272. then
  273. {
  274. iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.132 -m comment --comment "baloch2-device-in"
  275. }
  276. fi
  277. iptables -C TRAFFIC_ACCT_OUT --src 192.168.1.132 -m comment --comment "baloch2-device-out"
  278. if [ $? == 1 ]
  279. then
  280. {
  281. iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.132 -m comment --comment "baloch2-device-out"
  282. }
  283. fi
  284.  
  285.  
  286.  
  287. /etc/init.d/luci_statistics restart
  288.  
  289. # end of script
Add Comment
Please, Sign In to add comment