рдПрдХ рдЫреЛрдЯреЗ рдХрд╛рд░реНрдпрд╛рд▓рдп CentOS, Iptables, NAT, рд╕реНрдХреНрд╡рд┐рдб рдЯреНрд░рд╛рдВрд╕рдкреЗрд░реЗрдВрдЯ, рд╕рд░реНрдЧ рдХреЗ рд▓рд┐рдП рдПрдХ рдЗрдВрдЯрд░рдиреЗрдЯ рдЧреЗрдЯрд╡реЗ рдХреЙрдиреНрдлрд╝рд┐рдЧрд░ рдХрд░рдирд╛

рд╡реЗ рджрд┐рди рдЧрдП рдЬрдм рд╣рдорд╛рд░реЗ рдХрд╛рд░реНрдпрд╛рд▓рдп рдореЗрдВ 2 рдХрдВрдкреНрдпреВрдЯрд░ рдереЗ, рдФрд░ 2 рдПрдордмреАрдкреАрдПрд╕ рдЗрдВрдЯрд░рдиреЗрдЯ рдХреЗ рд╕рд╛рде 4 рдмрдВрджрд░рдЧрд╛рд╣реЛрдВ рдХреЗ рд▓рд┐рдП рдПрдХ рдбреАрдПрд╕рдПрд▓ рдореЙрдбреЗрдо рдерд╛
рд╕реНрдерд┐рддрд┐ рдХреЛ рдмрдЪрд╛рдпрд╛ред рдЕрдм рдХрд╛рд░реНрдпрд╛рд▓рдп рдореЗрдВ рдбреЗрд╡рд▓рдкрд░реНрд╕ рдХреЗ рдХрд╛рд░реНрдпреЛрдВ рдХреЗ рд▓рд┐рдП 5 рдХрд╛рд░реНрдпрд╢реАрд▓ рдорд╢реАрдиреЗрдВ рдФрд░ 1 рд╕рд░реНрд╡рд░ рд╣реИред

рдЬрдм рд╣рд░ рдХреЛрдИ рдПрдХ рдорд╛рдирдХ рдЯреАрдкреА рд▓рд┐рдВрдХ рдЧреЗрдЯрд╡реЗ рдХреЗ рд╕рд╛рде рд╕реНрд╡рд┐рдЪ рд╕реЗ рдЬреБрдбрд╝рд╛ рд╣реЛрддрд╛ рд╣реИ, рдЕрдЧрд░ рдХреЛрдИ рднреА рдбрд╛рдЙрдирд▓реЛрдб рдХрд░рдирд╛ рд╢реБрд░реВ рдХрд░ рджреЗрддрд╛ рд╣реИ, рддреЛ рдЗрдВрдЯрд░рдиреЗрдЯ рд╕рднреА рдХреЗ рд▓рд┐рдП рдлреНрд░реАрдЬ рд╣реЛ рдЬрд╛рдПрдЧрд╛ред рдЯреНрд░реИрдлрд┐рдХ рд╢реЗрдкрд░, рдбреАрдПрдирдПрд╕, рдбреАрдПрдЪрд╕реАрдкреА рдФрд░ рд╕рд╛рдВрдЦреНрдпрд┐рдХреА (рд╕реНрдХреНрд╡рд┐рдб + рд╕рд░реНрдЧ) рдФрд░ рдПрдХ рдкреНрд░реЙрдХреНрд╕реА рдХреЗ рд╕рд╛рде рдЕрдкрдирд╛ рдЗрдВрдЯрд░рдиреЗрдЯ рдЧреЗрдЯрд╡реЗ рдмрдирд╛рдиреЗ рдХрд╛ рдирд┐рд░реНрдгрдп рд▓рд┐рдпрд╛ рдЧрдпрд╛ред

рдПрдХ рд╕рд░реНрд╡рд░ рдХреЗ рд░реВрдк рдореЗрдВ, рдбреБрдЕрд▓рдХреЛрд░ рдкреЗрдВрдЯрд┐рдпрдо, 4 рдЬреАрдмреА рд░реИрдо рдХреЗ рд╕рд╛рде рд╕реЗрдВрдЯреЛрд╕ 6.4 рдиреНрдпреВрдирддрдо рдмреЛрд░реНрдб рдкрд░ рд╕реНрдерд╛рдкрд┐рдд рдХрд┐рдпрд╛ рдЧрдпрд╛ рдерд╛ред
рддреЛ, рдЪрд▓рд┐рдП рдЕрдкрдиреЗ рднрд╡рд┐рд╖реНрдп рдХреЗ рдЗрдВрдЯрд░рдиреЗрдЯ рдЧреЗрдЯрд╡реЗ рдХреЗ рдХреЙрдиреНрдлрд╝рд┐рдЧрд░реЗрд╢рди рдкрд░ рдЖрдЧреЗ рдмрдврд╝рддреЗ рд╣реИрдВред

рдХрд╛рд░реНрдп рдХреЙрдиреНрдлрд╝рд┐рдЧрд░ рдХрд░рдирд╛ рд╣реИ :
NAT (iptables, htb), DHCP, DNS, HTTPD, NGINX, SARG рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдЗрдВрдЯрд░рдиреЗрдЯ рдХрд╛ рд╡рд┐рддрд░рдг

рдкрд╣рд▓рд╛ рдХрджрдо, рдЖрд╡рд╢реНрдпрдХ рдмреБрдирд┐рдпрд╛рджреА рд╕реЙрдлрд╝реНрдЯрд╡реЗрдпрд░ рд╕реНрдерд╛рдкрд┐рдд рдХрд░рдирд╛

рдЖрд╡рд╢реНрдпрдХ рд░рд┐рдкреЙрдЬрд┐рдЯрд░реА рдЬреЛрдбрд╝реЗрдВ
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt rpm -ivh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm --import https://fedoraproject.org/static/0608B895.txt rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

YUM рдХреИрд╢ рд╕рд╛рдлрд╝ рдХрд░реЗрдВ
 yum clean all 

рдЕрд╕реЗрдВрдмрд▓реА рдХреЗ рд▓рд┐рдП рд╕реЙрдлрд╝реНрдЯрд╡реЗрдпрд░ рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 yum -y groupinstall "Development tools" 

рдЕрдиреНрдп рдЖрд╡рд╢реНрдпрдХ рдЙрдкрдпреЛрдЧрд┐рддрд╛рдУрдВ рдХреЛ рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 yum -y install git mc htop lftp unzip zlib zlib-devel openssl openssl-devel patch libtool re2c bison fprintd-pam subversion sshfs curlftpfs 


рджреВрд╕рд░рд╛ рдХрджрдо, рд╕реНрдерд╛рдкрд┐рдд nginx

 useradd nginx -s /bin/false -M -U mkdir /var/run/nginx/ chown -R nginx:nginx /var/run/nginx/ mkdir /var/log/nginx/ chown -R nginx:nginx /var/log/nginx/ cd /usr/src wget http://nginx.org/download/nginx-1.4.2.tar.gz tar xvzf nginx* cd nginx* git clone https://github.com/yaoweibin/nginx_tcp_proxy_module.git git clone git://github.com/mikewest/nginx-static-etags.git patch -p1 < nginx_tcp_proxy_module/tcp.patch wget -O release-1.6.29.5-beta.zip https://github.com/pagespeed/ngx_pagespeed/archive/release-1.6.29.5-beta.zip unzip release-1.6.29.5-beta.zip cd ngx_pagespeed-release-1.6.29.5-beta/ wget --no-check-certificate -O 1.6.29.5.tar.gz https://dl.google.com/dl/page-speed/psol/1.6.29.5.tar.gz tar -xzvf 1.6.29.5.tar.gz cd /usr/src/nginx* ./configure --error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/subsys/nginx --add-module=nginx-static-etags --add-module=nginx_tcp_proxy_module --add-module=ngx_pagespeed-release-1.6.29.5-beta --user=nginx --group=nginx --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --without-http_geo_module --without-http_ssi_module --without-http_empty_gif_module --without-http_browser_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-pcre=/usr/src/pcre-8.33 --without-http_memcached_module --without-http_scgi_module --without-http_uwsgi_module --without-http_fastcgi_module --http-fastcgi-temp-path= --http-uwsgi-temp-path= --prefix=/server/nginx --with-ipv6 make make install cd /server/nginx/conf/ && rm -f fastcgi.conf fastcgi.conf.default fastcgi_params fastcgi_params.default koi-utf koi-win mime.types.default nginx.conf.default scgi_params scgi_params.default uwsgi_params uwsgi_params.default win-utf mkdir /server/nginx/conf/conf.d/ 

Nginx.conf рдлрд╝рд╛рдЗрд▓ рдмрдирд╛рдПрдБ:
 touch /server/nginx/conf/nginx.conf 

Nginx.conf рд╕рд╛рдордЧреНрд░реА
 worker_processes 8; events { worker_connections 25000; use epoll; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; gzip on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json; gzip_comp_level 8; client_max_body_size 20M; server { listen 192.168.5.1:80 default_server; stub_status on; location = /apache-stats { proxy_pass http://127.0.0.1:80; } allow 192.168.5.1; deny all; } include conf.d/*.conf; } 

рдЪрд▓рд╛рдиреЗ рдХреЗ рд▓рд┐рдП рдлрд╝рд╛рдЗрд▓:
 touch /etc/init.d/nginx chmod +x /etc/init.d/nginx 


 #!/bin/bash # chkconfig: - 58 74 # # Source function library. . /etc/init.d/functions # Source networking configuration. . /etc/sysconfig/network if [ -f /etc/sysconfig/nginx ];then . /etc/sysconfig/nginx fi RETVAL=0 prog="nginx" start() { # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 1 echo -n $"Starting $prog: " daemon /server/nginx/sbin/nginx $OPTIONS RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nginx return $RETVAL } stop() { echo -n $"Shutting down $prog: " killproc /server/nginx/sbin/nginx RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/nginx return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status nginx RETVAL=$? ;; restart|reload) stop start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/nginx ]; then stop start RETVAL=$? fi ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=3 esac exit $RETVAL 


рддреАрд╕рд░рд╛ рдЪрд░рдг, httpd рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ


Apache рдХреЗ рд▓рд┐рдП рд╣рдо APR, APR-UTIL, PCRE рдбрд╛рд▓реЗрдВрдЧреЗ
APR рд╕реНрдерд╛рдкрдирд╛
 cd /usr/src wget http://apache.ip-connect.vn.ua//apr/apr-1.5.0.tar.gz tar xvzf apr-1.5.0* cd apr-1.5.0 ./configure --prefix=/server/misc/apr make make install 

APR-UTIL рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 yum -y install openldap-devel nss nss-devel cd /usr/src wget http://apache.ip-connect.vn.ua//apr/apr-util-1.5.3.tar.gz tar xvzf apr-util* cd apr-util-* ./configure --prefix=/server/misc/apr-util --with-apr=/server/misc/apr --with-crypto --with-ldap make make install 

PCRE рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 cd /usr/src wget http://ftp.exim.llorien.org/pcre/pcre-8.33.tar.gz tar xvzf pcre-8.33.tar.gz cd pcre* ./configure --prefix=/server/misc/pcre make make install 

APACHE рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 useradd apache -s /bin/false -M -U mkdir /var/run/httpd/ && chown -R apache:apache /var/run/httpd/ mkdir /var/log/httpd/ && chown -R apache:apache /var/log/httpd/ cd /usr/src wget http://mpm-itk.sesse.net/mpm-itk-2.4.4-04.tar.gz tar xvzf mpm* wget http://archive.apache.org/dist/httpd/httpd-2.4.6.tar.gz tar xvzf httpd* cp -r httpd-2.4.6 httpd-2.4.6.orig cd httpd-2.4.6 patch -p1 < /usr/src/mpm-itk-2.4.4-04/patches/r1389339-pre-htaccess-hook.diff rm -rf /usr/src/httpd-2.4.6.orig ./buildconf --with-apr=/usr/src/apr-1.4.8 --with-apr-util=/usr/src/apr-util-1.5.2 ./configure --prefix=/server/httpd --with-mpm=prefork --with-apr=/server/misc/apr --with-apr-util=/server/misc/apr-util --with-pcre=/server/misc/pcre --disable-version --disable-status --enable-rewrite=static --enable-realip=static --enable-mods-static="authn_file mime authn_core authz_host authz_groupfile authz_user authz_core access_compat auth_basic reqtimeout filter log_config env headers setenvif unixd dir alias realip status info" make make install cd /usr/src/mpm* ./configure --with-apxs=/server/httpd/bin/apxs make make install mkdir -p /server/httpd/conf/conf.d/sites/ rm -rf /server/httpd/man rm -rf /server/httpd/manual rm -rf /server/httpd/icons rm -rf /server/httpd/cgi-bin rm -rf /server/httpd/logs rm -rf /server/httpd/conf/extra rm -rf /server/httpd/conf/original mkdir /var/www chown root:root /var/www chown -R apache:apache /server/httpd 

рдЖрдЗрдП httpd.conf рдХреЛ рдЗрд╕ рдкреНрд░рдХрд╛рд░ рдареАрдХ рдХрд░реЗрдВ:
 ServerRoot "/server/httpd" Listen 127.0.0.1:80 LoadModule mpm_itk_module modules/mpm_itk.so LoadModule remoteip_module modules/mod_remoteip.so <IfModule unixd_module> User apache Group apache </IfModule> ServerAdmin webmaster@{HOSTNAME} ServerName {HOSTNAME} <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "/var/log/httpd/error_log" LogLevel warn PidFile /var/run/httpd/httpd.pid <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common CustomLog "/var/log/httpd/access_log" common #CustomLog "/var/log/httpd/logs/access_log" combined </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/server/httpd/cgi-bin/" </IfModule> <Directory "/server/httpd/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig conf/mime.types AddType application/x-compress .Z AddType application/x-gzip .gz .tgz </IfModule> <IfModule prefork.c> StartServers 6 MinSpareServers 5 MaxSpareServers 10 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 10000 </IfModule> ServerName 127.0.0.1 IncludeOptional conf/conf.d/*.conf IncludeOptional conf/conf.d/sites/*.conf # Timeout: The number of seconds before receives and sends time out. Timeout 60 # KeepAlive: Whether or not to allow persistent connections (more than one request per connection). Set to "Off" to deactivate. KeepAlive On # MaxKeepAliveRequests: The maximum number of requests to allow during a persistent connection. Set to 0 to allow an unlimited amount. We recommend you leave this number high, for maximum performance. MaxKeepAliveRequests 100 # KeepAliveTimeout: Number of seconds to wait for the next request from the same client on the same connection. KeepAliveTimeout 5 # Set to one of: Full | OS | Minor | Minimal | Major | Prod where Full conveys the most information, and Prod the least. ServerTokens Prod UseCanonicalName Off AccessFileName .htaccess ServerSignature Off HostnameLookups Off ExtendedStatus On <IfModule reqtimeout_module> RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500 </IfModule> <IfModule remoteip_module> RemoteIPHeader X-Forwarded-For RemoteIPInternalProxy 127.0.0.1 </IfModule> 

рдЪрд▓рд╛рдиреЗ рдХреЗ рд▓рд┐рдП рдПрдХ рдлрд╝рд╛рдЗрд▓ рдмрдирд╛рдПрдБ:
 touch /etc/init.d/httpd chmod +x /etc/init.d/httpd 

рд╕рд╛рдордЧреНрд░реА рдХреЗ рд╕рд╛рде:
 #!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: The Apache HTTP Server is an efficient and extensible \ # server implementing the current HTTP standards. # processname: httpd # config: /server/httpd/conf/httpd.conf # pidfile: /var/run/httpd/httpd.pid # ### BEGIN INIT INFO # Provides: httpd # Required-Start: $local_fs $remote_fs $network $named # Required-Stop: $local_fs $remote_fs $network # Should-Start: distcache # Short-Description: start and stop Apache HTTP Server # Description: The Apache HTTP Server is an extensible server # implementing the current HTTP standards. ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Start httpd in the C locale by default. HTTPD_LANG="C" # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based "worker" MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start. # Path to the apachectl script, server binary, and short-form for messages. apachectl=/server/httpd/bin/apachectl httpd=/server/httpd/bin/httpd prog=httpd pidfile=/var/run/httpd/httpd.pid lockfile=/var/lock/subsys/httpd RETVAL=0 STOP_TIMEOUT=10 # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting $prog: " LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } # When stopping httpd, a delay (of default 10 second) is required # before SIGKILLing the httpd parent; this gives enough time for the # httpd parent to SIGKILL any errant children. stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} } reload() { echo -n $"Reloading $prog: " if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then RETVAL=6 echo $"not reloading due to configuration syntax error" failure $"not reloading $httpd due to configuration syntax error" else # Force LSB behaviour from killproc LSB=1 killproc -p ${pidfile} $httpd -HUP RETVAL=$? if [ $RETVAL -eq 7 ]; then failure $"httpd shutdown" fi fi echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL=$? ;; restart) stop start ;; condrestart|try-restart) if status -p ${pidfile} $httpd >&/dev/null; then stop start fi ;; force-reload|reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}" RETVAL=2 esac exit $RETVAL 


рдЪреМрдерд╛ рдЪрд░рдг, рдЗрдВрдЯрд░рдиреЗрдЯ рдХрд╛ рд╡рд┐рддрд░рдг рд╕реНрдерд╛рдкрд┐рдд рдХрд░рдирд╛

рд╕рд░реНрд╡рд░ рдореЗрдВ рджреЛ рдиреЗрдЯрд╡рд░реНрдХ рдЗрдВрдЯрд░рдлреЗрд╕ рд╣реИрдВ:
eth0 - рдкреНрд░рджрд╛рддрд╛ рд╕реЗ рдЗрдВрдЯрд░рдиреЗрдЯ
eth1 - рд╣рдорд╛рд░рд╛ рд╕реНрдерд╛рдиреАрдп рдХреНрд╖реЗрддреНрд░ рдиреЗрдЯрд╡рд░реНрдХ

рд╕рд╛рдордЧреНрд░реА рдХреЗ рд╕рд╛рде / iptables рдлрд╝рд╛рдЗрд▓ рдмрдирд╛рдПрдБ:
 #!/bin/sh PATH=/usr/sbin:/sbin:/bin:/usr/bin # -   iptables -F iptables -t nat -F iptables -t mangle -F iptables -X iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -m state --state NEW ! -i eth0 -j ACCEPT iptables -A FORWARD -i eth0 -o eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to 192.168.5.1:3128 echo 1 > /proc/sys/net/ipv4/ip_forward 

рд╣рдо рдлрд╝рд╛рдЗрд▓ рдЪрд▓рд╛рдиреЗ рдХрд╛ рдЕрдзрд┐рдХрд╛рд░ рджреЗрддреЗ рд╣реИрдВ:
 chmod +x /iptables 

рд╣рдо рд▓реЙрдиреНрдЪ рдХрд░рддреЗ рд╣реИрдВ
 /iptables 

рдиреЗрдЯрд╡рд░реНрдХ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХрд╛ рд╕рдВрдкрд╛рджрди:
 mcedit /etc/sysconfig/network-scripts/ifcfg-eth1 

 DEVICE=eth1 HWADDR=00:0E:0C:73:E4:F9 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=192.168.5.1 NETMASK=255.255.255.0 GATEWAY=192.168.1.106 NETWORK=192.168.5.0 


рдЧреЗрдЯрд╡реЗ - рдЖрдИрдкреА eth0 рдЗрдВрдЯрд░рдлрд╝реЗрд╕

рдиреЗрдЯрд╡рд░реНрдХ рд░рд┐рдмреВрдЯ рдХрд░реЗрдВ:
 service network restart 


рдкрд╛рдВрдЪрд╡рд╛рдВ рдЪрд░рдг, dhcpd рд╕реЗрдЯрдЕрдк

рдЗрд╕реЗ рдпрдо рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ
 yum -y install dhcpd 

рдХреЙрдиреНрдлрд╝рд┐рдЧрд░:
 mcedit /etc/dhcp/dhcpd.conf 

 ddns-update-style none; ignore client-updates; DHCPARGS="eth1"; INTERFACES="eth1"; subnet 192.168.5.0 netmask 255.255.255.0 { range 192.168.5.100 192.168.5.200; option routers 192.168.5.1; option subnet-mask 255.255.255.0; option domain-name ".loc"; option domain-name-servers 192.168.5.1; option time-offset -18000; default-lease-time 21600; max-lease-time 43200; } host astraPC1 { hardware ethernet 00:21:91:91:11:42; fixed-address 192.168.5.6; } host astraPC2 { hardware ethernet D0:27:88:43:7E:AE; fixed-address 192.168.5.7; } host astraPC3 { hardware ethernet D0:27:88:43:7F:0E; fixed-address 192.168.5.8; } host astraPC4 { hardware ethernet 90:2B:34:BB:15:F2; fixed-address 192.168.5.9; } host astraPC5 { hardware ethernet 90:2B:34:BA:E1:55; fixed-address 192.168.5.10; } 


рдпрд╣рд╛рдВ рд╣рдордиреЗ рдбреАрдПрдирдПрд╕ рд╕рд░реНрд╡рд░, рд╣рдорд╛рд░реЗ рдкреНрд░рд╡реЗрд╢ рджреНрд╡рд╛рд░ рдХреЗ рдЖрдИрдкреА рдХреЛ рдЗрдВрдЧрд┐рдд рдХрд┐рдпрд╛ред рдбреАрдПрдирдПрд╕ рдХреЗ рд░реВрдк рдореЗрдВ рдХреБрдЫ рд╕рд░рд▓ рдЙрдкрдпреЛрдЧ рдХрд░рдирд╛ рддрд░реНрдХрд╕рдВрдЧрдд рд╣реИ, рдореИрдВрдиреЗ dnsmasq рдЪреБрдирд╛

рдЪрд░рдг рдЫрд╣, рдбреАрдПрдирдПрд╕ рд╕рд░реНрд╡рд░ рдХреЙрдиреНрдлрд╝рд┐рдЧрд░ рдХрд░реЗрдВ

 yum -y install dnsmasq 


рд╣рдордиреЗ рдкрд╣рд▓реЗ рд╣реА рдбреАрдПрдЪрд╕реАрдкреА рд╕реНрдерд╛рдкрд┐рдд рдХрд░ рд▓рд┐рдпрд╛ рд╣реИ, рд╣рдореЗрдВ рдмрд╛рдХреА рдХрд╛рд░реНрдпрдХреНрд╖рдорддрд╛ рдХреА рдЖрд╡рд╢реНрдпрдХрддрд╛ рдирд╣реАрдВ рд╣реИ, рдХреЙрдиреНрдлрд╝рд┐рдЧрд░ рдлрд╝рд╛рдЗрд▓ рдХрд╛рдлреА рд╕рд░рд▓ рд╣реИ, рд╕рд┐рджреНрдзрд╛рдВрдд рд░реВрдк рдореЗрдВ, рдХреЗрд╡рд▓ рд╡рд╣реА рд╢рд╛рдорд┐рд▓ рдХрд░реЗрдВ рдЬрд┐рд╕рдХреА рдЖрдкрдХреЛ рдЖрд╡рд╢реНрдпрдХрддрд╛ рд╣реИ
 interface=eth1 no-dhcp-interface=eth1 port=53 # -     /etc/hosts localise-queries all-servers # -     clear-on-reload # - DNS   server=192.168.1.1 


рд╣рдорд╛рд░реЗ рд╕реНрдерд╛рдиреАрдп рдиреЗрдЯрд╡рд░реНрдХ рдХреЗ рд▓рд┐рдП / etc / рдореЗрдЬрдмрд╛рди рдореЗрдВ, рдХреБрдЫ рдореЗрдЬрдмрд╛рдиреЛрдВ рдХреА рдЖрд╡рд╢реНрдпрдХрддрд╛ рдереА:
 192.168.5.1 sarg.loc 192.168.5.1 mysql.loc 


SARG - SQUID рдХреЗ рд▓рд┐рдП рд▓реЙрдЧ рдЬрдирд░реЗрдЯрд░

рдЪрд░рдг рд╕рд╛рдд, рд╕реНрдХреНрд╡реАрдб рд╕реНрдерд╛рдкрд┐рдд рдХрд░реЗрдВ

 yum -y install squid 

рд╣рдо рдХреЙрдиреНрдлрд╝рд┐рдЧрд░реЗрд╢рди рдлрд╝рд╛рдЗрд▓ рдХреЛ рдирд┐рдореНрди рд╕реНрдерд┐рддрд┐ рдореЗрдВ рдареАрдХ рдХрд░рддреЗ рд╣реИрдВ:
 acl manager proto cache_object acl localhost src 127.0.0.1/32 ::1 acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1 acl lan src 192.168.5.1/32 acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localnet http_access allow localhost http_access allow lan http_access deny all # -   http_port 3128 transparent hierarchy_stoplist cgi-bin ? coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 # -  squid    forwarded_for off request_header_access From deny all request_header_access Server deny all request_header_access Link deny all request_header_access X-Forwarded-For deny all request_header_access Via deny all request_header_access Cache-Control deny all visible_hostname myhost.com 


рд╕реНрдЯреЗрдк рдЖрда, рдЗрдВрд╕реНрдЯрд╛рд▓рд┐рдВрдЧ рд╕рд░реНрдЧ

 yum -y install sarg 

рдЪреВрдВрдХрд┐ рд╣рдорд╛рд░реЗ рд╕реНрдерд╛рдиреАрдп рдиреЗрдЯрд╡рд░реНрдХ рдореЗрдВ рд╕реЗрдЯрд┐рдВрдЧреНрд╕ рдорд╣рддреНрд╡рдкреВрд░реНрдг рдирд╣реАрдВ рд╣реИрдВ, рдорд╛рдирдХ рдорд╛рдирдХ рдХрд╛рдлреА рдЙрдкрдпреБрдХреНрдд рд╣реИрдВ, рдХреЗрд╡рд▓ рдПрдХ рдЪреАрдЬ рдлрд╝реЛрд▓реНрдбрд░ рдХреЛ рдирд┐рд░реНрджрд┐рд╖реНрдЯ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдереА рдЬрд╣рд╛рдВ рд▓реЙрдЧ рдХреЛ рдмрдЪрд╛рдиреЗ рдХреЗ рд▓рд┐рдП, рдЗрд╕ рд░рд╛рдЬреНрдп рдореЗрдВ рдХреЙрдиреНрдлрд╝рд┐рдЧрд░реЗрд╢рди рдлрд╝рд╛рдЗрд▓ рдХреЛ рд╕рдВрдкрд╛рджрд┐рдд рдХрд░реЗрдВ:
 mcedit /usr/local/etc/sarg.conf 

 output_dir /var/www/sarg/public_html/sarg.loc 

рдпрд╣ рд╕рд▓рд╛рд╣ рджреА рдЬрд╛рддреА рд╣реИ рдХрд┐ рдПрд╕рдПрдЖрд░рдЬреА рдХреЛ рдореБрдХреБрдЯ рдореЗрдВ рдЬреЛрдбрд╝рд╛ рдЬрд╛рдП рддрд╛рдХрд┐ рдпрд╣ рд╣рд░ рджрд┐рди рдЖрдВрдХрдбрд╝реЗ рд╕рдВрдЧреНрд░рд╣реАрдд рдХрд░реЗред рдХрдорд╛рдВрдб рдЪрд▓рд╛рдХрд░ рд▓реЙрдЧ рдЬрдирд░реЗрдЯ рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВ:
 sarg 


рдЪрд░рдг рдиреМ, HTB рдХреЙрдиреНрдлрд╝рд┐рдЧрд░ рдХрд░реЗрдВ

 wget -O /etc/init.d/htb wget http://downloads.sourceforge.net/project/htbinit/HTB.init/0.8.5/htb.init-v0.8.5?use_mirror=citylan 

рд╢реЗрдкрд░ рд╕реЗрдЯрд┐рдВрдЧреНрд╕ рдЖрдкрдХреА рдЖрд╡рд╢реНрдпрдХрддрд╛рдУрдВ рдкрд░ рдирд┐рд░реНрднрд░ рдХрд░рддреА рд╣реИрдВред рд╣рдорд╛рд░реЗ рдорд╛рдорд▓реЗ рдореЗрдВ, рд╕реНрд░реЛрдд рдбреЗрдЯрд╛ рдерд╛:
рдЪреИрдирд▓ рдЪреМрдбрд╝рд╛рдИ: 6Mbit / рд╕реЗрдХрдВрдб
рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛: 5
рдиреЛрдЯ: рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рд╢рд╛рдпрдж рд╣реА рдХрднреА рдбрд╛рдЙрдирд▓реЛрдб рдХрд░рддреЗ рд╣реИрдВ, рдЕрдХреНрд╕рд░ рдЗрдВрдЯрд░рдиреЗрдЯ рдкрд░ рд╕рд░реНрдл рдХрд░рддреЗ рд╣реИрдВред

рд╣рдо рдлрд╛рдЗрд▓ рдмрдирд╛рддреЗ рд╣реИрдВ:
 cd /etc/sysconfig/htb touch eth1 touch eth1-2.root touch eth1-2:06.astraPC1 touch eth1-2:07.astraPC2 touch eth1-2:08.astraPC3 touch eth1-2:09.astraPC4 touch eth1-2:10.astraPC5 


eth1 - рд╣рдорд╛рд░реЗ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХреА рд░реВрдЯ рдлрд╝рд╛рдЗрд▓
# - рд╢реЗрдкрд░ рд╕рдЯреАрдХрддрд╛
 R2Q=20 DEFAULT=0 


eth1-2.root - рд╕рдВрдкреВрд░реНрдг рд╢реНрд░реГрдВрдЦрд▓рд╛ рдХреЗ рд▓рд┐рдП рдирд┐рдпрдореЛрдВ рдХреЛ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд░реЗрдВ
 RATE=6Mbit CEIL=6Mbit 


eth1-2: 06.astraPC1 - рдорд╢реАрди рдХреЗ рд▓рд┐рдП рдлрд╝рд╛рдЗрд▓, рд╕реБрд╡рд┐рдзрд╛ рдХреЗ рд▓рд┐рдП, рдлрд╝рд╛рдЗрд▓ рдПрдХреНрд╕рдЯреЗрдВрд╢рди рдХрдВрдкреНрдпреВрдЯрд░ рдХрд╛ рдореЗрдЬрдмрд╛рди рд╣реИ, рдФрд░ рдЙрдкрд╕рд░реНрдЧ рдЖрдИрдкреА рдХрд╛ рдЕрдВрддрд┐рдо рдСрдХреНрдЯреЗрдЯ рд╣реИ
 BURST=100kb RATE=1024Kbit CEIL=3064Kbit LEAF=sfq PRIO=1 RULE=192.168.5.6 


рд╢реЗрд╖ рдлрд╛рдЗрд▓реЗрдВ рд╕рд╛рджреГрд╢реНрдп рджреНрд╡рд╛рд░рд╛ рдмрдирд╛рдИ рдЧрдИ рд╣реИрдВред

Source: https://habr.com/ru/post/In205460/


All Articles