オフィスに2台のコンピューターがあり、2 Mbpsのインターネットを備えた4ポートのDSLモデムがあった時代は終わりました
状況を保存しました。 現在、オフィスには、開発者のタスク用に5台の作業マシンと1台のサーバーがあります。
誰もが標準のTp Linkゲートウェイを使用してスイッチに接続しているときに、誰かがダウンロードを開始すると、インターネットは誰にとってもフリーズします。 トラフィックシェーパー、DNS、DHCP、統計(squid + sarg)およびプロキシを使用して、独自のインターネットゲートウェイを作成することが決定されました。
サーバーとして、CentOS 6.4最小搭載の4 GB RAMを搭載したDualCore pentiumが選択されました。
それでは、将来のインターネットゲートウェイの構成に進みましょう。
タスクは設定することです:
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
2番目のステップ、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
3番目のステップ、httpdのインストール
Apacheの場合、APR、APR-UTIL、PCREを配置します4月のインストール
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
実行するファイルを作成します。
touch /etc/init.d/httpd chmod +x /etc/init.d/httpd
コンテンツ付き:
4番目のステップ、インターネットの配布のセットアップ
サーバーには2つのネットワークインターフェイスがあります。
eth0-プロバイダーからのインターネット
eth1-ローカルエリアネットワーク
次の内容で/ iptablesファイルを作成します。
ファイルを実行する権利を付与します。
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
ゲートウェイ-IP eth0インターフェイス
ネットワークを再起動します。
service network restart
5番目のステップ、dhcpdセットアップ
yumからインストールする
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; }
ここでは、ゲートウェイのIPであるdnsサーバーを示しました。 DNSのような単純なものを使用するのは論理的で、dnsmasqを選択しました
ステップ6、DNSサーバーを構成する
yum -y install dnsmasq
DHCPは既にインストールされています。残りの機能は必要ありません。設定ファイルは非常にシンプルで、原則として、必要なものだけが含まれています
interface=eth1 no-dhcp-interface=eth1 port=53
/ etc / hostsでは、ローカルネットワークにいくつかのホストが必要でした:
192.168.5.1 sarg.loc 192.168.5.1 mysql.loc
SARG-SQUIDのログジェネレーター
ステップ7、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
ステップ8、Sargのインストール
yum -y install sarg
ローカルネットワークでは設定は重要ではないため、標準の設定は非常に適切です。唯一のことは、ログを保存するフォルダーを指定し、構成ファイルを次の状態に編集することです。
mcedit /usr/local/etc/sarg.conf
output_dir /var/www/sarg/public_html/sarg.loc
統計を毎日保存するために、クラウンにSARGを追加することをお勧めします。 次のコマンドを実行すると、ログが生成されます。
sarg
ステップ9、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-マシンのファイル。便宜上、ファイル拡張子はコンピューターのホストであり、プレフィックスはIPの最後のオクテットです。
BURST=100kb RATE=1024Kbit CEIL=3064Kbit LEAF=sfq PRIO=1 RULE=192.168.5.6
残りのファイルは類推によって作成されます。