Advertisement
budiana

Debian Proxy Server Mikrotik sejajar Klien

Jul 19th, 2012
1,676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.19 KB | None | 0 0
  1. Installasi UNBOUND DNS server dan LUSCA di Debian Squeeze
  2. host proxy.hade.war.net
  3. ip 192.168.2.25
  4. gw 192.168.2.30
  5.  
  6. topologi :
  7. Proxy and Cleint connect to SWITCH and using same subnet.
  8.  
  9. echo deb http://kambing.ui.ac.id/debian/ squeeze main | tee -a /etc/apt/sources.list
  10. echo deb http://download.webmin.com/download/repository sarge contrib | tee -a /etc/apt/sources.list
  11. cd /root
  12. wget http://www.webmin.com/jcameron-key.asc
  13. apt-key add jcameron-key.asc
  14. apt-get -y update && apt-get -y upgrade && apt-get -y install unbound dnsutils webmin
  15.  
  16. cd /etc/unbound
  17. wget  ftp://FTP.INTERNIC.NET/domain/named.cache
  18. unbound-control-setup
  19. chown unbound:root unbound_*
  20. chmod 440 unbound_*
  21.  
  22. nano /etc/unbound/unbound.conf
  23.  
  24. server:
  25.         verbosity: 1
  26.         statistics-interval: 120
  27.         num-threads: 1
  28.         interface: 0.0.0.0
  29.  
  30.         outgoing-range: 512
  31.         num-queries-per-thread: 1024
  32.  
  33.         msg-cache-size: 16m
  34.         rrset-cache-size: 32m
  35.  
  36.         msg-cache-slabs: 4
  37.         rrset-cache-slabs: 4
  38.  
  39.         cache-max-ttl: 86400
  40.         infra-host-ttl: 60
  41.         infra-lame-ttl: 120
  42.  
  43.         infra-cache-numhosts: 10000
  44.         infra-cache-lame-size: 10k
  45.  
  46.         do-ip4: yes
  47.         do-ip6: no
  48.         do-udp: yes
  49.         do-tcp: yes
  50.         do-daemonize: yes
  51.  
  52.         access-control: 192.168.0.0/16 allow
  53.         #access-control: 172.16.0.0/12 allow
  54.         #access-control: 10.0.0.0/8 allow
  55.         access-control: 127.0.0.0/8 allow
  56.         access-control: 0.0.0.0/0 refuse
  57.  
  58.         chroot: "/etc/unbound"
  59.         username: "unbound"
  60.         directory: "/etc/unbound"
  61.         #logfile: "/etc/unbound/unbound.log"
  62.         #use-syslog: yes
  63.         logfile: ""
  64.         use-syslog: no
  65.         pidfile: "/etc/unbound/unbound.pid"
  66.         root-hints: "/etc/unbound/named.cache"
  67.  
  68.         identity: "ns.hade.war.net"
  69.         version: "1.4"
  70.         hide-identity: yes
  71.         hide-version: yes
  72.         harden-glue: yes
  73.         do-not-query-address: 127.0.0.1/8
  74.         do-not-query-localhost: yes
  75.         module-config: "iterator"
  76.  
  77.         #zone localhost
  78.         local-zone: "localhost." static
  79.         local-data: "localhost. 10800 IN NS localhost."
  80.         local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800"
  81.         local-data: "localhost. 10800 IN A 127.0.0.1"
  82.  
  83.         local-zone: "127.in-addr.arpa." static
  84.         local-data: "127.in-addr.arpa. 10800 IN NS localhost."
  85.         local-data: "127.in-addr.arpa. 10800 IN SOA localhost. nobody.invalid. 2 3600 1200 604800 10800"
  86.         local-data: "1.0.0.127.in-addr.arpa. 10800 IN PTR localhost."
  87.  
  88.         #zone hade.war.net
  89.         local-zone: "hade.war.net." static
  90.         local-data: "hade.war.net. 86400 IN NS ns.hade.war.net."
  91.         local-data: "hade.war.net. 86400 IN SOA hade.war.net. hostmaster.hade.war.net.  3 3600 1200 604800 86400"
  92.         local-data: "hade.war.net. 86400 IN A 192.168.2.25"
  93.         local-data: "www.hade.war.net. 86400 IN A 192.168.2.25"
  94.         local-data: "ns.hade.war.net. 86400 IN A 192.168.2.25"
  95.         local-data: "ftp.hade.war.net. 86400 IN A 192.168.2.25"
  96.         local-zone: "2.168.192.in-addr.arpa." static
  97.         local-data: "2.168.192.in-addr.arpa. 10800 IN NS hade.war.net."
  98.         local-data: "2.168.192.in-addr.arpa. 10800 IN SOA hade.war.net. hostmaster.hade.war.net. 4 3600 1200 604800 864000"
  99.         local-data: "25.2.168.192.in-addr.arpa. 10800 IN PTR hade.war.net."
  100.  
  101.     # Use or own ISP , opendns, nawala or google
  102.     forward-zone:
  103.         name: "."
  104.         forward-addr: 203.130.208.18
  105.         forward-addr: 203.130.193.74
  106.         forward-addr: 208.67.222.222
  107.         forward-addr: 208.67.220.220
  108.         forward-addr: 180.131.144.144
  109.         forward-addr: 180.131.145.145
  110.         forward-addr: 8.8.8.8
  111.         forward-addr: 8.8.4.4
  112.  
  113. remote-control:
  114.         control-enable: yes
  115.         control-interface: 127.0.0.1
  116.         control-port: 953
  117.         server-key-file: "/etc/unbound/unbound_server.key"
  118.         server-cert-file: "/etc/unbound/unbound_server.pem"
  119.         control-key-file: "/etc/unbound/unbound_control.key"
  120.         control-cert-file: "/etc/unbound/unbound_control.pem"
  121.  
  122. Save file
  123.  
  124. cat > /etc/resolv.conf << "EOF"
  125. # Begin /etc/resolv.conf
  126. domain proxy.hade.war.net
  127. nameserver 127.0.0.1
  128. nameserver 192.168.2.30
  129. # End /etc/resolv.conf
  130. EOF
  131.  
  132. unbound-checkconf /etc/unbound/unbound.conf
  133.  
  134. reboot
  135.  
  136. Tuning Up
  137.  
  138. Optimalkan file system cache & ubah opsi untuk partisi cache
  139.  
  140. Disabled fsck (file system check)
  141. nano /etc/fstab
  142.  
  143. Angka standart Drive Cache adalah 0 2 ——>> ganti dengan 0 0 (INGAT HANYA DRIVE CACHE)
  144.  
  145. Opsi Directory /cache :
  146. Apabila menggunakan reiserfs gunakan opsi noatime,notail    0   0
  147. Apabila menggunakan ext4 gunakan opsi noatime,barrier=0     0   0
  148. Apabila menggunakan btrfs gunakan opsi noatime,compress,noacl   0   0
  149.  
  150. Adjusting tcp sockets and limits
  151.  
  152. decrease TCP TIME_WAIT setting, the default value (60 in Debian 6) is too high and will result in too many sockets in TIME_WAIT stait. To decrease waiting time, execute following command:
  153.  
  154. echo 4 > /proc/sys/net/ipv4/tcp_fin_timeout
  155.  
  156. To verify setting is in effect, use:
  157. cat /proc/sys/net/ipv4/tcp_fin_timeout # Output should show "4"
  158.  
  159.  
  160. echo 256000 > /proc/sys/fs/file-max # Adjust system-wide number of open files
  161. ulimit -n 63535                     # Sets number of open files for this process and it's children
  162.  
  163. Verify your settings with:
  164. cat /proc/sys/fs/file-max # Shows number of files and sockets for this system, must be at least 128000
  165. ulimit -a                 # Show user limits, check "core file size" and "open files"
  166.  
  167. echo "*        soft        nofile          65536" >> /etc/security/limits.conf
  168. echo "*        hard        nofile          65536" >> /etc/security/limits.conf
  169. echo "root     soft        nofile          65536" >> /etc/security/limits.conf
  170. echo "root     hard        nofile          65536" >> /etc/security/limits.conf
  171. echo "proxy    soft        nofile          65536" >> /etc/security/limits.conf
  172. echo "proxy    hard        nofile          65536" >> /etc/security/limits.conf
  173. echo "session required        pam_limits.so" >> /etc/pam.d/common-session
  174.  
  175. modprobe ip_conntrack
  176.  
  177. kemudian tambahkan ip_contrack di /etc/modules
  178. nano /etc/modules
  179.  
  180. tambahkan kalimat berikut baris paling bawah :
  181.  
  182. ip_conntrack
  183.  
  184. Edit the /etc/profile file and ensure that the file does not contain any commands that set ulimit values.
  185. Add the following commands to the end of the /etc/profile file
  186.  
  187. ulimit -Hn 65536
  188. ulimit -Sn 32768
  189. ulimit -s 2097152
  190.  
  191. Modifying conntrack capacity
  192. CONNTRACK_MAX = RAMSIZE (in bytes) / 16384 / (x / 32)
  193. where x is the number of bits in a pointer (for example, 32 or 64 bits).
  194.  
  195. For total number of connection just edit /etc/sysctl.conf
  196.  
  197. nano /etc/sysctl.conf
  198.  
  199. fs.file-max=65536
  200. vm.drop_caches = 3
  201. vm.swappiness = 3
  202. net.netfilter.nf_conntrack_acct= 1
  203. net.ipv4.netfilter.ip_conntrack_max = 245000
  204. net.ipv4.tcp_keepalive_time = 60
  205. net.ipv4.tcp_keepalive_intvl = 10
  206. net.ipv4.tcp_keepalive_probes = 6
  207. net.ipv4.tcp_timestamps = 0
  208. net.ipv4.tcp_sack = 0
  209. net.ipv4.tcp_synack_retries = 2
  210. net.ipv4.tcp_syn_retries = 2
  211. net.ipv4.tcp_max_tw_buckets = 1440000
  212. net.ipv4.ip_local_port_range = 16384 65535
  213. net.core.rmem_max=16777216
  214. net.core.wmem_max=16777216
  215. net.ipv4.tcp_rmem=4096 87380 16777216
  216. net.ipv4.tcp_wmem=4096 65536 16777216
  217. net.ipv4.tcp_fin_timeout = 3
  218. net.core.netdev_max_backlog = 30000
  219. net.ipv4.tcp_no_metrics_save=1
  220. net.core.somaxconn = 262144
  221. net.ipv4.tcp_syncookies = 0
  222. net.ipv4.tcp_max_orphans = 262144
  223. net.ipv4.tcp_max_syn_backlog = 262144
  224. net.ipv4.tcp_tw_reuse = 1
  225. net.ipv4.tcp_tw_recycle = 1
  226. net.ipv4.conf.default.rp_filter = 1
  227. net.ipv4.conf.default.accept_source_route = 0
  228. kernel.sysrq = 0
  229. kernel.core_uses_pid = 1
  230. kernel.msgmnb = 65536
  231. kernel.msgmax = 65536
  232. kernel.shmmax = 4294967295
  233. kernel.shmall = 268435456
  234. net.ipv6.conf.all.disable_ipv6 = 1
  235. net.ipv6.conf.default.disable_ipv6 = 1
  236. net.ipv6.conf.lo.disable_ipv6 = 1
  237.  
  238. setelah di save,
  239.  
  240. sysctl -p
  241.  
  242. catatan : utk ram 512Mb kurangi saja parameter *mem di kolom ke dua dan tiga menjadi setengahnya, kolom ke satu biarkan saja
  243.  
  244. Reboot CPU nya…
  245.  
  246. apt-get install -y squid squidclient squid-cgi gcc build-essential sharutils ccze libzip-dev automake1.9 && wget http://proxy-ku.googlecode.com/files/LUSCA_FMI.tar.gz && tar xzvf LUSCA_FMI.tar.gz && cd LUSCA_FMI/ && make distclean
  247.  
  248. ./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-http-gzip --enable-async-io=24 --with-aufs-threads=24 --with-pthreads --enable-storeio=aufs,coss,null --enable-linux-netfilter --enable-arp-acl --enable-epoll --enable-pf-transparent --enable-removal-policies=lru,heap --with-aio --with-dl --enable-snmp --enable-delay-pools --enable-htcp --enable-cache-digests --disable-unlinkd --enable-large-cache-files --with-large-files --enable-err-languages=English --enable-default-err-language=English --with-maxfd=65536 && make && make install
  249.  
  250. cd /etc/squid/
  251. wget http://proxy-ku.googlecode.com/files/storeurl.pl
  252.  
  253. cd /etc/init.d/
  254. wget http://proxy-ku.googlecode.com/files/squid
  255.  
  256. cd /etc/squid/
  257. wget http://proxy-ku.googlecode.com/files/squid.conf
  258. rm squid.conf && mv squid.conf.1 squid.conf
  259. chmod +x /etc/init.d/squid && /etc/init.d/squid stop
  260.  
  261. edit squid.conf sesuai kondisi
  262. cache
  263. mime_table /etc/squid/mime.conf
  264. etc
  265.  
  266. chown proxy:proxy /cache* && chmod 777 /cache* && chown proxy:proxy /etc/squid/storeurl.pl && chmod 777 /etc/squid/storeurl.pl && chmod +x /etc/init.d/squid
  267. squid -z
  268.  
  269. Bila tak ada error teruskan dengan
  270. squid -f /etc/squid/squid.conf -z && /etc/init.d/squid start
  271.  
  272. iptables -F
  273. iptables -X
  274. iptables -t nat -F
  275. iptables -t nat -X
  276. iptables -t mangle -F
  277. iptables -t mangle -X
  278. iptables -P INPUT ACCEPT
  279. iptables -P OUTPUT ACCEPT
  280. iptables -A INPUT -s 192.168.0.0/16 -m state --state NEW -p tcp --dport 53 -j ACCEPT
  281. iptables -A INPUT -s 192.168.0.0/16 -m state --state NEW -p udp --dport 53 -j ACCEPT
  282. iptables -A INPUT -p tcp -s 192.168.0.0/16 --dport 80 -j ACCEPT
  283. iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
  284. iptables-save -c > /etc/iptables.up.rules
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement