furrywall 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/bash
  2. ############ CONFIGURATION SECTION ############
  3. LAN_IF="INTERNAL_INTERFACE"
  4. WAN_IF="EXTERNAL_INTERFACE"
  5. LAN_NET="INTERNAL_NETWORK"
  6. LAN_CIDR="INTERNAL_CIDR"
  7. BANDWIDTH="1024mbit"
  8. ###############################################
  9. IPT="/sbin/iptables"
  10. IPS="/sbin/ipset"
  11. TC="/sbin/tc"
  12. WAN_IP=`ip addr show ${WAN_IF} | grep inet' '| awk {'print $2'} | cut -f 1 -d "/" | sed -n '1p' | xargs`
  13. /sbin/modprobe ip_conntrack
  14. /sbin/modprobe ip_conntrack_ftp
  15. /sbin/modprobe ip_nat_ftp
  16. $IPT -F
  17. $IPT -X
  18. $IPS -N FORW iphash
  19. $IPS -N DISCON iphash
  20. $IPT -P INPUT ACCEPT
  21. $IPT -P OUTPUT ACCEPT
  22. $IPT -P FORWARD DROP
  23. $IPT -A INPUT -m state --state INVALID -j DROP
  24. $IPT -A FORWARD -i lo -j ACCEPT
  25. $IPT -A FORWARD -m state --state INVALID -j DROP
  26. $IPT -A FORWARD -m set --match-set FORW src,dst -j ACCEPT
  27. $IPT -A FORWARD -m set --match-set FORW dst,src -j ACCEPT
  28. $IPT -A FORWARD -m set --match-set DISCON src --dst ${WAN_IP} -j ACCEPT
  29. $IPT -A FORWARD -m set --match-set DISCON dst --src ${WAN_IP} -j ACCEPT
  30. #UHW
  31. #$IPT -t nat -A PREROUTING --src 172.31.0.0/24 --dst 0.0.0.0/0 -p tcp --dport 80 -j DNAT --to-destination 172.31.0.1:80
  32. #NAT
  33. $IPT -t nat -A POSTROUTING -s ${LAN_NET}/${LAN_CIDR} -o ${WAN_IF} -j SNAT --to-source ${WAN_IP}
  34. #Shaper
  35. $IPT -t mangle --flush
  36. $TC qdisc add dev ${LAN_IF} root handle 1: htb
  37. $TC class add dev ${LAN_IF} parent 1: classid 1:1 htb rate ${BANDWIDTH} ceil ${BANDWIDTH}
  38. $TC qdisc add dev ${WAN_IF} root handle 1: htb
  39. $TC class add dev ${WAN_IF} parent 1: classid 1:1 htb rate ${BANDWIDTH} ceil ${BANDWIDTH}
  40. #starting bandwidthd
  41. service bandwidthd start
  42. # /
  43. # __ //
  44. # -\= \=\ //
  45. # --=_\=---//=--
  46. # -_==/ \/ //\/--
  47. # ==/ /O O\==--
  48. # _ _ _ _ /_/ \ ] /--
  49. # /\ ( (- \ / ] ] ]==-
  50. # (\ _\_\_\-\__/ \ (,_,)--
  51. #(\_/ \ \-
  52. #\/ / ( ( \ ] /)
  53. #/ ( \ \_ \./ )
  54. #( \ \ ) \
  55. #( /\_ _ _ _ /---/ /\_ \
  56. # \ / \ / ____/ / \ \
  57. # ( / ) / / /__ ) ( )
  58. # ( ) / __/ '---` / /
  59. # \ / \ \ _/ /
  60. # ] ] )_\_ /__\/
  61. # /_\ ]___\
  62. # (___)