Linux/Apache.md
... ...
@@ -0,0 +1,457 @@
1
+[[_TOC_]]
2
+
3
+- [[Perl/ApacheErrorLogFormatter]]
4
+----
5
+# ドキュメント
6
+- [Apache HTTP Server Documentation](http://httpd.apache.org/docs/)
7
+ - [Version 2.2](http://httpd.apache.org/docs/2.2/)
8
+
9
+ - [mod_authz_host](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html) ([mod_access](http://httpd.apache.org/docs/2.0/mod/mod_access.html))
10
+ - Allow, Deny, Order ディレクティブ
11
+
12
+ - [mod_setenvif](http://httpd.apache.org/docs/2.2/mod/mod_setenvif.html)
13
+
14
+ - [Apache の SSL/TLS 暗号化](http://httpd.apache.org/docs/2.2/ssl/)
15
+
16
+# Apache用モジュールをコンパイルできるようにする
17
+- httpd-devel (apxs) をインストールしておく。
18
+```
19
+# yum install httpd-devel
20
+```
21
+
22
+# バーチャルホスト設定
23
+- [バーチャルホスト説明書](http://httpd.apache.org/docs/2.2/vhosts/)
24
+
25
+## 設定
26
+- /etc/httpd/conf.d/VirtualHosts.conf
27
+```apache
28
+# Use name-based virtual hosting.
29
+NameVirtualHost *:80
30
+
31
+<VirtualHost *:80>
32
+ ServerName www.takeash.net
33
+ DocumentRoot /var/www/html/
34
+</VirtualHost>
35
+
36
+<VirtualHost *:80>
37
+ ServerName vh1.takeash.net
38
+ DocumentRoot /var/www/vh1-html/
39
+ <Directory "/var/www/vh1-html">
40
+# AllowOverride All
41
+ </Directory>
42
+</VirtualHost>
43
+```
44
+
45
+## エラー対策
46
+- バーチャルホストが表示されない。
47
+ - エラーメッセージ
48
+```
49
+[warn] _default_ VirtualHost overlap on port 80, the first has precedence
50
+```
51
+ - 原因<br />
52
+NameVirtualHost ディレクティブが設定されていない。
53
+ - 対処<br />
54
+NameVirtualHost ディレクティブを設定する。<br />
55
+httpd.conf を修正するより conf.d に VirtualHosts.conf として専用のファイルを作成しておく方が忘れなくていいかも。
56
+
57
+# Digest 認証
58
+- [認証、承認、アクセス制御](http://httpd.apache.org/docs/2.2/howto/auth.html)
59
+- [mod_auth_digest](http://httpd.apache.org/docs/2.2/mod/mod_auth_digest.html)
60
+ - レルム/ユーザ/パスワード追加
61
+```
62
+htdigest [-c] passwdfile <realm> <username>
63
+```
64
+ - /etc/httpd/conf.d/DigestAuth.conf
65
+```apache
66
+<Directory "/var/www/html/Download/<realm>">
67
+ AllowOverride AuthConfig
68
+ AuthType Digest
69
+ AuthName "<realm>"
70
+ AuthUserFile /var/www/passwd/passwords_digest
71
+ Require user <username>
72
+ Options None
73
+ Options Indexes
74
+ DirectoryIndex index.html index.htm index.php
75
+ Order allow,deny
76
+ Allow from all
77
+</Directory>
78
+```
79
+
80
+# mod_ssl
81
+- インストール
82
+```
83
+# yum install mod_ssl
84
+```
85
+
86
+## 自己署名証明書使用
87
+
88
+- SAN 項目を追加した設定ファイルを作成。
89
+```
90
+# cd /etc/pki/tls/
91
+# cp openssl.cnf openssl-san.cnf
92
+```
93
+
94
+- openssl.cnf と openssl-san.cnf の差分
95
+```
96
+--- openssl.cnf
97
++++ openssl-san.cnf
98
+@@ -104,7 +104,7 @@
99
+ ####################################################################
100
+ [ req ]
101
+ default_bits = 2048
102
+-default_md = sha1
103
++default_md = sha256
104
+ default_keyfile = privkey.pem
105
+ distinguished_name = req_distinguished_name
106
+ attributes = req_attributes
107
+@@ -222,6 +222,11 @@
108
+
109
+ basicConstraints = CA:FALSE
110
+ keyUsage = nonRepudiation, digitalSignature, keyEncipherment
111
++subjectAltName=@alt_names
112
++
113
++[ alt_names ]
114
++DNS.1=takeash.net
115
++DNS.2=*.takeash.net
116
+
117
+[ v3_ca ]
118
+
119
+```
120
+- 証明書フォルダへ移動
121
+```
122
+# cd certs/
123
+```
124
+
125
+- サーバー用秘密鍵作成 (server.key)
126
+```
127
+# openssl genrsa -aes128 2048 > server.key
128
+```
129
+
130
+- パスフレーズ削除<br />
131
+httpd 再起動時にパスフレーズが要求されないようにするため。
132
+```
133
+# openssl rsa -in server.key -out server.key
134
+```
135
+
136
+- サーバー用自己署名証明書作成 (server.crt)
137
+```
138
+# openssl req -utf8 -new -key server.key -x509 -days 3650 -out server.crt -set_serial 0 \
139
+ -subj '/C=JP/ST=Tokyo/L=Chuo-ku/O=TakeAsh.net/CN=takeash.net' -extensions v3_req -config ../openssl-san.cnf
140
+```
141
+ - サブジェクト例 (TakeAsh.net)
142
+| C | 国名コード | JP |
143
+| --- | --- | --- |
144
+| ST | 都道府県 | Tokyo |
145
+| L | 区市町村 | Chuo-ku |
146
+| O | 組織名 | TakeAsh.net |
147
+| CN | コモンネーム(ドメイン名) | takeash.net |
148
+ - 証明書確認<br />
149
+「X509v3 extensions - X509v3 Subject Alternative Name」項目が存在すれば SAN が含まれている。
150
+```
151
+# openssl x509 -in server.crt -text
152
+...
153
+ X509v3 Subject Alternative Name:
154
+ DNS:takeash.net, DNS:*.takeash.net
155
+...
156
+```
157
+
158
+- /etc/httpd/conf.d/ssl.conf (抜粋)
159
+```
160
+SSLCertificateFile /etc/pki/tls/certs/server.crt
161
+SSLCertificateKeyFile /etc/pki/tls/certs/server.key
162
+DocumentRoot "/var/www/html"
163
+SSLProtocol all -SSLv2 -SSLv3
164
+```
165
+
166
+- httpd 再起動
167
+ - CentOS 6
168
+```
169
+# service httpd restart
170
+```
171
+ - CentOS 7
172
+```
173
+# systemctl restart httpd
174
+```
175
+
176
+- 動作テスト
177
+ - https://takeash.net/cgi-bin/etc/PrintEnv.cgi
178
+ - https://www.takeash.net/cgi-bin/etc/PrintEnv.cgi
179
+
180
+- [OpenSSL CSR with Alternative Names one-line - End Point Blog](http://blog.endpoint.com/2014/10/openssl-csr-with-alternative-names-one.html)
181
+- [SAN対応 x.509 証明書を取得するためのCSRを作成する - Qiita](http://qiita.com/saitara/items/eda74ac6a950122b5f31)
182
+- [subjectAltNameでバーチャルホスト - Kung Noi Blog](http://www.goodnai.com/blog/2010/05/07/subjectaltname%E3%81%A7%E3%83%90%E3%83%BC%E3%83%81%E3%83%A3%E3%83%AB%E3%83%9B%E3%82%B9%E3%83%88/)
183
+- [Webサーバー間通信内容暗号化(Apache+mod_SSL) - CentOSで自宅サーバー構築](http://centossrv.com/apache-ssl.shtml)
184
+- [SSL Server Test (Powered by Qualys SSL Labs)](https://www.ssllabs.com/ssltest/)
185
+- [ssl certificate - how to add subject alernative name to ssl certs? - Stack Overflow](https://stackoverflow.com/questions/%38%37%34%34%36%30%37)
186
+ - keytool -certreq -ext SAN=dns:example.com,ip:192.168.0.1
187
+ - [keytool(ja)](https://docs.oracle.com/javase/jp/8/docs/technotes/tools/windows/keytool.html) / [keytool(en)](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/keytool.html)
188
+
189
+## Certbot 使用
190
+- Certbot 使用前準備
191
+ - ホスト名が正引きできること。(ワイルドカード不可)
192
+ - バーチャルホストのサーバ名と要求するドメイン名のどれかが一致すること。
193
+ - https でアクセス可能になっていること。
194
+ - https ポート解放
195
+```
196
+# firewall-cmd --add-service=https --permanent
197
+```
198
+
199
+- Certbot インストール (EPEL リポジトリ)
200
+```
201
+# yum install python-certbot-apache
202
+```
203
+
204
+- 証明書取得<br />
205
+取得に成功すると「/etc/letsencrypt/live/<ドメイン1>/」に証明書が作成される。
206
+```
207
+# certbot --apache certonly -m <メールアドレス> -d <ドメイン1> [-d <ドメイン2> ...] --agree-tos
208
+```
209
+
210
+- /etc/httpd/conf.d/ssl.conf (抜粋)
211
+```
212
+SSLCertificateFile /etc/letsencrypt/live/<ドメイン1>/cert.pem
213
+SSLCertificateKeyFile /etc/letsencrypt/live/<ドメイン1>/privkey.pem
214
+SSLCertificateChainFile /etc/letsencrypt/live/<ドメイン1>/chain.pem
215
+```
216
+
217
+- 自動更新スクリプト /etc/cron.monthly/certbot.sh
218
+```bash
219
+#!/bin/bash
220
+/bin/certbot renew
221
+```
222
+
223
+- [Certbot](https://certbot.eff.org/)
224
+- [Webサーバー間通信内容暗号化(Apache+mod_SSL+Certbot) - CentOSで自宅サーバー構築](http://centossrv.com/apache-certbot.shtml)
225
+
226
+## Certbot 使用(ワイルドカード)
227
+- Certbot インストール (EPEL リポジトリ)
228
+```
229
+# yum -y install yum-utils
230
+# yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
231
+# yum install certbot-apache
232
+```
233
+
234
+- 証明書取得(手動)<br />
235
+途中HTTPへのテキストファイルの配置とDNSへのTXTレコードの追加を指示されるので、追加してからEnterを押して先へ進む。<br />
236
+取得に成功すると「/etc/letsencrypt/live/<ドメイン>/」に証明書が作成される。
237
+```
238
+# certbot certonly --manual --server https://acme-v02.api.letsencrypt.org/directory -d "*.example.com" -d example.com
239
+```
240
+
241
+- /etc/httpd/conf.d/ssl.conf (抜粋)
242
+```
243
+SSLCertificateFile /etc/letsencrypt/live/<ドメイン>/cert.pem
244
+SSLCertificateKeyFile /etc/letsencrypt/live/<ドメイン>/privkey.pem
245
+SSLCertificateChainFile /etc/letsencrypt/live/<ドメイン>/chain.pem
246
+```
247
+
248
+- apache 再起動
249
+```
250
+# systemctl restart httpd.service
251
+```
252
+
253
+- 証明書更新<br />
254
+「--manual」で取得した場合は「renew」による自動更新ができないので、既存の証明書を削除し同名で取得し直す。
255
+```
256
+# certbot delete
257
+```
258
+
259
+- 証明書の有効期限を表示<br />
260
+getExpireDate.sh
261
+```bash
262
+#!/bin/bash
263
+
264
+CommonName=example.net
265
+
266
+NotAfter=`openssl x509 -noout -dates -in /etc/letsencrypt/live/${CommonName}/fullchain.pem | \
267
+ grep notAfter | \
268
+ sed -e "s/notAfter=//" | \
269
+ date -f - --iso-8601`
270
+echo ${NotAfter}
271
+```
272
+
273
+# mod_security
274
+## インストール
275
+- EPELリポジトリ
276
+```
277
+# yum install mod_security mod_security_crs
278
+```
279
+
280
+## 設定
281
+- /etc/httpd/conf.d/mod_security.conf (抜粋)
282
+```apache
283
+ # Maximum request body size we will
284
+ # accept for buffering
285
+ #SecRequestBodyLimit 131072
286
+ SecRequestBodyLimit 5242880
287
+ SecRequestBodyNoFilesLimit 51200
288
+```
289
+
290
+- /etc/httpd/modsecurity.d/modsecurity_localrules.conf
291
+```apache
292
+# Drop your local rules in here.
293
+
294
+# White List IP
295
+SecRule REMOTE_ADDR "@pmFromFile /etc/httpd/modsecurity.d/whitelist_ip.txt" \
296
+ "phase:1,id:'1000001',nolog,allow,ctl:ruleEngine=Off,ctl:auditEngine=Off"
297
+
298
+# White List URI
299
+SecRule REQUEST_URI "@pmFromFile /etc/httpd/modsecurity.d/whitelist_uri.txt" \
300
+ "phase:1,id:'1000002',nolog,allow,ctl:ruleEngine=Off,ctl:auditEngine=Off"
301
+
302
+# White List URI 2
303
+SecRule REQUEST_URI "@rx ^\/Etc\/" \
304
+ "phase:1,id:'1000003',nolog,allow,ctl:ruleEngine=Off,ctl:auditEngine=Off"
305
+
306
+ # White List Sub-Domain
307
+ SecRule REQUEST_HEADERS:Host "@pmFromFile /etc/httpd/modsecurity.d/whitelist_subdomain.txt" \
308
+ "phase:1,id:'1000004',nolog,allow,ctl:ruleEngine=Off,ctl:auditEngine=Off"
309
+
310
+# ZmEu Attack / phpMyAdmin
311
+SecRule REQUEST_URI "@rx (?i)\/(php-?My-?Admin[^\/]*|mysqlmanager|myadmin|pma2005|pma\/scripts|w00tw00t[^\/]+)\/" \
312
+ "severity:alert,id:'0000013',deny,log,status:400,msg:'Unacceptable folder.',severity:'2'"
313
+```
314
+ - mod_security-2.7.1 でエラーが出るから適当にid追加したけど、idの振り方のルールってどこにあるのかな?
315
+```
316
+ModSecurity: No action id present within the rule
317
+```
318
+
319
+- /etc/httpd/modsecurity.d/whitelist_ip.txt<br />
320
+mod_security による制限を行わない IP アドレスを列挙する。<br />
321
+コメントは行頭から「#」で始める。
322
+```
323
+# localhost
324
+127.0.0.1
325
+
326
+# example.com
327
+xxx.xxx.xxx.xxx
328
+
329
+# example.net
330
+yyy.yyy.yyy.yyy
331
+```
332
+
333
+- /etc/httpd/modsecurity.d/whitelist_uri.txt<br />
334
+mod_security による制限を行わない URI を列挙する。
335
+```
336
+/cgi-bin/etc/PrintEnv.cgi
337
+/cgi-bin/etc/PrintEnv_txt.cgi
338
+/cgi-bin/etc/index.cgi
339
+/cgi-bin/etc/testCGI.cgi
340
+```
341
+
342
+- /etc/httpd/modsecurity.d/whitelist_subdomain.txt<br />
343
+mod_security による制限を行わないホスト名を列挙する。
344
+```
345
+# WebApp1
346
+vh1.takeash.net
347
+```
348
+
349
+- /etc/httpd/modsecurity.d/activated_rules/modsecurity_crs_20_protocol_violations.conf
350
+ - id:958291 "Range: 0-", mp4 等のストリーミングや分割ダウンロードが行われるファイルのダウンロードで引っかかる。
351
+
352
+## リンク
353
+- http://modsecurity.org/
354
+ - [Reference Manual](https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual)
355
+ - [The Open Web Application Security Project](https://www.owasp.org/)
356
+- [hashdos攻撃をmod_securityで防御する(CentOS+yum編) - 徳丸浩の日記](http://blog.tokumaru.org/2012/01/hashdosmodsecuritycentosyum.html)
357
+- [Attack by ZmEu - The Linux Page](http://linux.m2osw.com/zmeu-attack) phpMyAdmin 脆弱性スキャンスクリプト対策
358
+- [黒ぶちメガネのblog » mod_securityのホワイトリスト、ブラックリストの書き方メモ](http://www.kurobuti.com/blog/?p=3775)
359
+- [禁煙できないSEの独り言: ModSecurity 2.5.12の導入](http://hiro-system.blog.ocn.ne.jp/blog/2010/04/modsecurity_251.html)
360
+- [(続)spammer対策 - ねこ様にもてあそばれる日々(2006-05-03)](http://m9841.info/?date=20060503#p02)
361
+- [mod_securityでWebサーバを守る(第1回) - ソフテック](http://www.softek.co.jp/Sec/mod_security1.html)
362
+- Webアプリケーションに潜むセキュリティホール
363
+ - [Webアプリケーションファイアウォールによる防御](http://www.atmarkit.co.jp/fsecurity/rensai/webhole11/webhole01.html)
364
+ - [mod_securityのXSS対策ルールを作成する](http://www.atmarkit.co.jp/fsecurity/rensai/webhole12/webhole01.html)
365
+- [UNIX的なアレ:gihyo.jp出張所](http://gihyo.jp/admin/serial/01/unix)
366
+ - [第19回 知っておきたいApacheの基礎知識 その15](http://gihyo.jp/admin/serial/01/unix/0019)
367
+
368
+# mod_geoip
369
+## インストール
370
+- EPELリポジトリ
371
+```
372
+yum install mod_geoip
373
+```
374
+
375
+## 設定
376
+- /etc/cron.monthly/updateGeoIP<br />
377
+データベースの自動更新スクリプト
378
+```bash
379
+wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
380
+gunzip GeoIP.dat.gz
381
+mv -f GeoIP.dat /usr/share/GeoIP/GeoIP.dat
382
+/sbin/restorecon -v /usr/share/GeoIP/GeoIP.dat
383
+```
384
+- GeoIP が表示されない場合は、SELinux のラベルを確認。
385
+```
386
+# ls -Z /usr/share/GeoIP/
387
+Good) unconfined_u:object_r:usr_t:s0
388
+NG) unconfined_u:object_r:admin_home_t:s0
389
+```
390
+ラベルが正しくない場合は下記コマンドで修正する。
391
+```
392
+# sealert -a /var/log/audit/audit.log
393
+# /sbin/restorecon -v /usr/share/GeoIP/GeoIP.dat
394
+```
395
+ラベル修正後、httpd を再起動すること。
396
+```
397
+# service httpd restart
398
+```
399
+
400
+## リンク
401
+- [MaxMind](http://www.maxmind.com/)
402
+ - [mod_geoip2 Apache module](http://dev.maxmind.com/geoip/mod_geoip2)
403
+ - [GeoLite Free Downloadable Databases](http://dev.maxmind.com/geoip/geolite)
404
+- [Apache2 mod_geoip CentOS うざい国を弾くモジュール « ORBIT SPACE](http://www.orsx.net/blog/archives/2510)
405
+
406
+# Apacheでhttp-equiv属性値を反映させる
407
+- [META要素「http-equiv属性値とHTTPヘッダー」について考える](http://www.infoaxia.com/tools/blog/archives/cat3/)
408
+- [Apache mod_xml_charset](http://www.yoshidam.net/XML_ja.html)
409
+
410
+- デフォルトでは、LastModifiedしか反映されない。
411
+- apxsはhttpd-devel-xxx.rpmをインストールすることで使用できるようになる。
412
+- うちの Fedora Core 3 環境だとmod_html_metaのコンパイルでエラーが出るんでまだ使えていない。引き続き検討。
413
+
414
+# Apache に DoS 攻撃対策 mod_evasive
415
+- [mod_evasive](http://www.zdziarski.com/blog/?page_id=442) @ [Jonathan Zdziarski's Domain](http://www.zdziarski.com/)
416
+- [Apache DoS攻撃対策 mod_evasiveインストール&設定 &#8211; Linux](http://www.makizou.com/archives/1341) @ [MAKIZOU.COM](http://www.makizou.com/)
417
+
418
+# cgi-bin ディレクトリでファイル名を省略したときに index.cgi を実行する設定
419
+- httpd.conf に ScriptAliasMatch を追加する。
420
+
421
+- 修正前
422
+```apache
423
+ScriptAlias /cgi-bin/ /var/www/cgi-bin/
424
+```
425
+
426
+- 修正後
427
+```apache
428
+ScriptAliasMatch ^/cgi-bin/(.*)\.cgi /var/www/cgi-bin/$1.cgi
429
+ScriptAliasMatch ^/cgi-bin/(.*)/? /var/www/cgi-bin/$1/index.cgi
430
+ScriptAliasMatch ^/cgi-bin$ /var/www/cgi-bin/index.cgi
431
+ScriptAlias /cgi-bin/ /var/www/cgi-bin/
432
+```
433
+
434
+- index.cgi の例
435
+```perl
436
+#!/usr/local/bin/perl
437
+
438
+use strict;
439
+use warnings;
440
+use utf8;
441
+use CGI::Pretty;
442
+
443
+my $q = new CGI;
444
+my $host = $q->url(-base => 1);
445
+print $q->redirect( $host . '/' );
446
+
447
+# EOF
448
+```
449
+
450
+- [Apacheで、http://hoge.hoge/cgi-bin/foo/にアクセスできるようにする方法](http://blogs.dion.ne.jp/fit_si/archives/5941241.html)
451
+
452
+# Apache で外部からの直リンクを禁止する
453
+- [404 Blog Not Found:Apache - ホットリンクを禁止する](http://blog.livedoor.jp/dankogai/archives/50804992.html)
454
+
455
+# Basic認証にタイムアウトを設定する
456
+- [mod_auth_timeout](http://secure.linuxbox.com/tiki/tiki-index.php?page=mod_auth_timeout)
457
+- [サードパーティー製認証モジュール](http://www.thinkit.co.jp/article/120/3/2.html)
... ...
\ No newline at end of file
Linux/Customize.md
... ...
@@ -0,0 +1,217 @@
1
+[[_TOC_]]
2
+
3
+# nautilus設定
4
+- フォルダを開くたびに新しいウィンドウを開かないようにする
5
+```
6
+gconftool-2 --type bool --set /apps/nautilus/preferences/always_use_browser true
7
+```
8
+- ツールバーの設定
9
+ 1. 「システム - 設定 - ルック&フィール - 外観の設定」を起動
10
+ 1. 「インターフェース」タブで、「アイコンの下にラベル」から「アイコンの横にラベル」へ変更
11
+
12
+# DynamicDNSの自動更新
13
+
14
+- [DiCE](http://www.hi-ho.ne.jp/yoshihiro_e/dice/)
15
+- [[updateEarth>Perl/updateEarth]]
16
+
17
+# Apache
18
+- [[Linux/Apache]]へ移動。
19
+
20
+# NICの冗長化
21
+- [[Linux/NIC_Bonding]]へ移動。
22
+
23
+# ユーザにシェルを使わせない
24
+- useradd でユーザを追加する際にシェルとして存在しないものを指定することで、メールやftp等は使用できるがコマンド操作はできないユーザを作成することができる。
25
+```
26
+# useradd -s /bin/nologin ユーザ名
27
+```
28
+- 各ユーザの現在のシェル設定は /etc/password に記録されている。
29
+```
30
+# grep "ユーザ名" /etc/password | awk -F":" '{print $7}'
31
+```
32
+- 既存ユーザの設定変更は usermod で行う。
33
+```
34
+# usermod -s /bin/nologin ユーザ名
35
+```
36
+- useradd の -D オプションで既定値の確認、変更ができる。
37
+```
38
+# useradd -D
39
+GROUP=100
40
+HOME=/home
41
+INACTIVE=-1
42
+EXPIRE=
43
+SHELL=/bin/bash
44
+SKEL=/etc/skel
45
+CREATE_MAIL_SPOOL=yes
46
+# useradd -D -s /bin/nologin
47
+# useradd -D
48
+GROUP=100
49
+HOME=/home
50
+INACTIVE=-1
51
+EXPIRE=
52
+SHELL=/bin/nologin
53
+SKEL=/etc/skel
54
+CREATE_MAIL_SPOOL=yes
55
+```
56
+
57
+# 言語設定
58
+- "C" だと漢字が表示されない。"ja_JP.UTF-8" に変更する。
59
+- /etc/sysconfig/i18n
60
+```
61
+#LANG="C"
62
+LANG="ja_JP.UTF-8"
63
+SYSFONT="latarcyrheb-sun16"
64
+```
65
+- [日本語文字化け(UTF-8)](http://www.nina.jp/server/redhat/fedora/utf-8.html)
66
+
67
+# crontab からのメールの文字化け対策
68
+- メールの charset 指定が不適切。
69
+```
70
+Content-Type: text/plain; charset=ANSI_X3.4-1968
71
+```
72
+- 環境変数 CONTENT_TYPE を指定する。
73
+- 必要ならば環境変数 LANG も追加。
74
+- crontab 実行時に設定されている環境変数はメールヘッダ X-Cron-Env で確認できる。
75
+```
76
+CONTENT_TYPE=text/plain; charset=UTF-8
77
+LANG=ja_JP.UTF-8
78
+30 3 * * * /usr/bin/command
79
+```
80
+- [Man page of CRONTAB](http://linuxjm.sourceforge.jp/html/cron/man5/crontab.5.html)
81
+- anacron の場合は /etc/anacrontab で設定。
82
+- /etc/environment でも環境変数設定ができる。こちらで設定した場合は crontab に記述する必要はない。設定後、crond の再起動が必要。
83
+```
84
+service crond restart
85
+```
86
+
87
+# ディスクイメージ書き込み
88
+- K3b http://www.k3b.org/ <br />
89
+base リポジトリ
90
+```
91
+# yum install k3b
92
+```
93
+
94
+- ISO Master http://littlesvr.ca/isomaster/ <br />
95
+epel リポジトリ
96
+```
97
+# yum install isomaster
98
+```
99
+
100
+# USBメモリをマウント
101
+```
102
+mount -t vfat /dev/sdc1 /mnt/usbfm
103
+```
104
+- [murasaki (another HotPlug)](http://www.dotaster.com/~shuu/linux/murasaki/index_ja.html)
105
+
106
+# USB-HDD (NTFS) をマウント
107
+- NTFS のファイルシステムタイプをインストール。(epelリポジトリ)
108
+```
109
+# yum install ntfs-3g ntfsprogs
110
+# ln -s /bin/ntfsfix /sbin/fsck.ntfs-3g
111
+```
112
+- ディスク情報確認。<br />
113
+システムが「HPFS/NTFS」になっているデバイスがマウントすべきパーティション。
114
+```
115
+# fdisk -l
116
+```
117
+- マウントポイント作成。
118
+```
119
+# mkdir /mnt/usbhdd
120
+```
121
+- マウント。<br />
122
+マウントすべきパーティションが /dev/sdc5 だった場合。
123
+```
124
+# mount -t ntfs-3g /dev/sdc5 /mnt/usbhdd
125
+```
126
+- 取り外し。
127
+```
128
+# umount /mnt/usbhdd
129
+```
130
+- ディスクの UUID 確認。
131
+ - blkid コマンドまたは「ls -l /dev/disk/by-uuid/」で確認。
132
+- UUID を基にマウント。
133
+```
134
+# mount -t ntfs-3g UUID=xxxxxxxx /mnt/usbhdd
135
+```
136
+- /etc/fstab を設定することで起動時に自動でマウントできる。
137
+```
138
+UUID=xxxxxxxx /mnt/usbhdd ntfs-3g defaults 1 2
139
+```
140
+- 初期化順序が悪くて(?)自動マウントができない場合は、/etc/rc.d/rc.local に mount コマンドを書くといいかも。
141
+
142
+- [How to Mount an NTFS Filesystem](http://wiki.centos.org/TipsAndTricks/NTFS)
143
+
144
+- [LinuxでUSB外付けディスクを快適にマウントする - Colspan Blog](http://colspan.net/blog/2008/11/15222550.html)
145
+
146
+- [WikiPedia.ja:NTFS-3G](http://ja.wikipedia.org/wiki/%4e%54%46%53%2d%33%47)
147
+ - NTFS-3G はNTFSジャーナリングを部分的にサポートしているだけなので、コンピュータのクラッシュや電源断が発生すると、ファイルシステムが一貫していない状態になってしまう。これが発生したときにはWindowsで立ち上げて、NTFSにジャーナルを再実行させる必要がある。
148
+
149
+- [Ext2Fsd Project](http://www.ext2fsd.com/) Windows に Ext2/Ext3/Ext4 なドライブをマウント
150
+
151
+- [CentOS GPTディスクの追加方法](http://www.unix-power.net/linux/gpt.html) @ [UnixPower on Networking](http://www.unix-power.net/)
152
+
153
+# Windows ネットワーク共有フォルダをマウント
154
+| ファイル共有サーバのUNC名 | winsrv |
155
+| --- | --- |
156
+| 共有フォルダ名 | sharedfolder |
157
+| ファイル共有サーバのアカウント名 | user1 |
158
+| ファイル共有サーバのパスワード | secret |
159
+| マウントポイント | /mnt/winfolder |
160
+```
161
+# mount -t cifs -o username=user1,password="secret" //winsrv/sharedfolder /mnt/winfolder
162
+```
163
+
164
+# リモートデスクトップ接続
165
+## FreeRDP のインストール
166
+```
167
+yum install freerdp
168
+```
169
+
170
+## Gnome パネルにショートカットを追加
171
+1. パネル上で右クリックし、「パネルへ追加」を選択。
172
+1. 「カスタム・アプリケーションのランチャ」をダブルクリック。
173
+1. ランチャの作成
174
+| 種類 | 端末内で起動する |
175
+| --- | --- |
176
+| 名前 | <PC名> |
177
+| コマンド | /usr/bin/xfreerdp -g 800x600 -u <ユーザ名> <PC名> |
178
+| コメント | <任意> |
179
+
180
+- 「引き出し」を使って階層化できる。
181
+- Windows をアップグレードすると、「host key」が変わりアクセスできなくなる。<br />
182
+「~/.freerdp/known_hosts」から古いキーをコメントアウトしてからアクセスすることで現在のキーを追加できる。
183
+
184
+# mv でプログレスバーを表示
185
+- &#x7e;/.bashrc
186
+```
187
+alias rsynccopy="rsync --partial --progress --append --rsh=ssh -r -h"
188
+alias rsyncmove="rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files"
189
+```
190
+- 設定を即座に反映。
191
+```
192
+$ source ~/.bashrc
193
+```
194
+
195
+- [mv with progress bar](http://www.linuxquestions.org/questions/linux-general-1/mv-with-progress-bar-428705/)
196
+
197
+# 古いカーネルの削除
198
+- /boot の空き容量が不足してカーネルのアップデートができない場合に古いカーネルを削除する。
199
+- 使用容量の確認
200
+```
201
+# df -h
202
+```
203
+- インストール済みカーネルの確認
204
+```
205
+# rqm -q kernel
206
+```
207
+- yum-utils のインストール
208
+```
209
+# yum -y install yum-utils
210
+```
211
+- 古いカーネルの削除, --count は残す世代数
212
+```
213
+# package-cleanup --oldkernels --count 2
214
+```
215
+
216
+- [Yum と Yum リポジトリの設定 - 導入ガイド](https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html-single/Deployment_Guide/index.html#sec-Configuring_Yum_and_Yum_Repositories)
217
+: installonly_limit=value|value は、installonlypkgs 指示文に表示されている単一のパッケージに同時にインストール可能なバージョンの最大数を表す整数です。<br />デフォルト値は、installonly_limit=3 です。また、この値を低く、特に 2 より下に設定することは推奨されません。
... ...
\ No newline at end of file
Linux/Home.md
... ...
@@ -0,0 +1,2 @@
1
+[[_TOC_]]
2
+
Linux/Install.md
... ...
@@ -0,0 +1,62 @@
1
+[[_TOC_]]
2
+~~#ls2~~
3
+
4
+# インストールのトラブル
5
+
6
+## 変なパーティションが作成されてしまって、インストーラが進まない
7
+~linux rescue で boot し、fdisk コマンドで不要なパーティションを削除する。
8
+
9
+# セキュリティ・レベルの設定
10
+ファイアウォールのオプション/ポートの開放
11
+```
12
+vnc:tcp, swat:tcp, netbios-ssn:tcp, netbios-dgm:udp, netbios-ns:udp, ntp:udp, 53:tcp, 53:udp
13
+```
14
+SELinux/Samba
15
+```
16
+[v] Sambaがユーザーのホームディレクトリを共有することを許可する。
17
+```
18
+
19
+# ポート番号の割り当て
20
+- [Internet Assigned Numbers Authority](http://www.iana.org/)
21
+ - [Well Known Ports](http://www.iana.org/assignments/port-numbers)
22
+ - [MIME Media Types](http://www.iana.org/assignments/media-types/)
23
+
24
+# 不要なポートが開いていないか確認
25
+- [Sygate Online Services](http://scan.sygate.com/)
26
+
27
+# 回線速度測定
28
+- [BBエキサイト スピードテスト](http://speedtest.excite.co.jp/) (Flash)
29
+- [通信速度測定システム Radish Network Speed Testing](http://netspeed.studio-radish.com/) (Java)
30
+
31
+# オープンリゾルバ確認
32
+- [オープンリゾルバ確認サイト](http://www.openresolver.jp/)
33
+- [コマンドラインからの確認方法](https://www.jpcert.or.jp/pr/2013/pr130002.html#cli)
34
+```
35
+$ wget -qO - http://www.openresolver.jp/cli/check.html
36
+```
37
+
38
+# ディストリビューション名/バージョンの確認
39
+- コマンドラインから次のコマンドをタイプ。
40
+```
41
+$ cat /etc/issue
42
+```
43
+- また、/etc/ 下に「(ディストリビューション名)-release」というファイルがあるのでこちらを cat しても良い。
44
+```
45
+$ cat /etc/redhat-release
46
+$ cat /etc/fedora-release
47
+```
48
+- [インストールした Linux ディストリビューション名とバージョンを確認するには](http://d.hatena.ne.jp/PRiMENON/20080119/1200750903)
49
+
50
+# カーネルバージョンの確認
51
+- コマンドラインから次のコマンドをタイプ
52
+```
53
+$ uname -a
54
+```
55
+
56
+# 電源遮断
57
+- poweroff コマンドまたは shutdown コマンドを使う。
58
+```
59
+# poweroff
60
+# shutdown -h now
61
+```
62
+- shutdown コマンドの -h オプションを付けないと、シングルユーザモードになるだけで電源は切れない。
... ...
\ No newline at end of file
Linux/Install/CentOS6.md
... ...
@@ -0,0 +1,781 @@
1
+[[_TOC_]]
2
+----
3
+# 言語設定
4
+- /etc/sysconfig/i18n
5
+```
6
+LANG="ja_JP.UTF-8"
7
+SYSFONT="latarcyrheb-sun16"
8
+SUPPORTED="ja_JP.UTF-8:ja_JP:ja"
9
+```
10
+- &#x7e;/.bashrc に追加
11
+```
12
+export LANG=ja_JP.UTF-8
13
+```
14
+- 日本語サポートパッケージ追加
15
+```
16
+# yum groupinstall "Japanese Support"
17
+```
18
+
19
+# IPv6 無効化
20
+1. /etc/sysctl.conf に追加。
21
+```
22
+net.ipv6.conf.all.disable_ipv6 = 1
23
+net.ipv6.conf.default.disable_ipv6 = 1
24
+```
25
+1. /etc/sysconfig/network に以下を追加。
26
+```
27
+NETWORKING_IPV6=no
28
+```
29
+1. /etc/modprobe.d/disable-ipv6.conf を新規作成。
30
+```
31
+options ipv6 disable=1
32
+```
33
+1. OS から再起動。
34
+ - 「service network restart」では反映されない。
35
+
36
+- [How do I disable IPv6?](http://wiki.centos.org/FAQ/CentOS6#head-d47139912868bcb9d754441ecb6a8a10d41781df) @ [Questions about CentOS 6](http://wiki.centos.org/FAQ/CentOS6)
37
+- [CentOS 6でIPv6を無効にするには « smilemark blog](http://www.smilemark.net/blog/archives/2011/08/disable-ipv6-centos6.php)
38
+
39
+## Postfix エラー対応
40
+- /etc/postfix/main.cf 修正。(all だと IPv4,IPv6 の両方を有効にしようとするので、IPv4 のみ有効にする)
41
+```
42
+#inet_protocols = all
43
+inet_protocols = ipv4
44
+```
45
+
46
+- [Postfix IPv6 Support - Configuration](http://www.postfix.org/IPV6_README.html#configuration)
47
+- [Postfix IPv6サポート - 設定](http://www.postfix-jp.info/trans-2.3/jhtml/IPV6_README.html#configuration)
48
+
49
+## Dovecot 起動失敗対応
50
+- /etc/dovecot/dovecot.conf に追加。(IPv4のみ有効)
51
+```
52
+listen = *
53
+```
54
+
55
+# スケルトン設定
56
+- ssh
57
+```
58
+# mkdir /etc/skel/.ssh
59
+# chmod 700 /etc/skel/.ssh
60
+```
61
+- ftp
62
+```
63
+# mkdir /etc/skel/etc
64
+# cp /etc/localtime /etc/skel/etc/
65
+```
66
+- dovecot
67
+```
68
+# mkdir -p /etc/skel/Maildir/{new,cur,tmp}
69
+# chmod -R 700 /etc/skel/Maildir/
70
+```
71
+
72
+# ssh
73
+- 公開鍵, 秘密鍵作成 (該当ユーザとして作業する)
74
+```
75
+# su anyone
76
+$ cd ~/.ssh/
77
+$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
78
+Enter file in which to save the key (/home/anyone/.ssh/id_dsa): [Enter](変更なし)
79
+Enter passphrase (empty for no passphrase): <パスフレーズ>を入力
80
+Enter same passphrase again: <パスフレーズ>確認
81
+...
82
+$ ls -l (id_dsa, id_dsa.pub の2つができていることを確認)
83
+$ mv id_dsa.pub authorized_keys
84
+$ cat id_dsa (秘密鍵をローカルに保存するため表示)
85
+$ rm id_dsa (TeraTerm等でログインできることを確認した後削除)
86
+$ exit
87
+```
88
+
89
+# ブートメッセージ表示
90
+- /etc/grub.conf<br />
91
+「kernel」行の中の「rhgb quiet」を削除すると、ブート時にメッセージが表示されるようになる。
92
+
93
+# プロキシ設定
94
+- [プロキシ下でLinuxを使う際のメモ](http://lambdalisue.hatenablog.com/entry/2013/06/25/140630) @ [Λlisue's blog](http://lambdalisue.hatenablog.com/)
95
+- [CentOSでのproxy設定](https://sites.google.com/site/mine1868/Home/centos/centosde-no-proxysettei) @ [明鏡止水のメモ](https://sites.google.com/site/mine1868/)
96
+
97
+# postfix
98
+
99
+## リレー設定
100
+- /etc/postfix/isp_passwd
101
+```
102
+[mail.example.com] isp_acount:isp_password
103
+```
104
+- パスワードDB作成
105
+```
106
+# postmap /etc/postfix/isp_passwd
107
+```
108
+- /etc/postfix/main.cf
109
+```
110
+relayhost = [mail.example.com]
111
+smtp_sasl_auth_enable = yes
112
+smtp_sasl_password_maps = hash:/etc/postfix/isp_passwd
113
+smtp_sasl_security_options = noanonymous
114
+smtp_sasl_mechanism_filter = plain, login
115
+```
116
+
117
+- [OP25B対策(Outbound Port 25 Blocking対策)](http://www.aconus.com/~oyaji/mail2/op25b.htm) @ [パ ソコンおやじ](http://www.aconus.com/~oyaji/)
118
+
119
+# ディスプレイ設定
120
+
121
+## Out of Range
122
+- CPU切替器(KVM)は高解像度に対応しているのにモニタがその解像度に対応していないため、「Out of Range」となり画面が映らない場合、Xorgでモニタの対応周波数を指定する。ブート途中は画面が映らないが、Xorg 起動後は正常に表示される。
123
+
124
+1. /etc/inittab を編集し、Run Level を 5 から 3 に変更。
125
+1. Reboot
126
+1. xorg.conf の雛形を作成。
127
+```
128
+# Xorg -configure
129
+```
130
+1. 雛形を既定のディレクトリへ移動
131
+```
132
+# mv /root/xorg.conf.new /etc/X11/xorg.conf
133
+```
134
+1. SELinux が有効の場合はラベルし直し
135
+```
136
+# restorecon -v /etc/X11/xorg.conf
137
+```
138
+1. /etc/X11/xorg.conf の Section "Monitor" にモニタがサポートしている走査周波数(水平/垂直)を追加する。
139
+```
140
+Section "Monitor"
141
+ Identifier "Monitor0"
142
+ VendorName "Monitor Vendor"
143
+ ModelName "Monitor Model"
144
+ HorizSync 40-70
145
+ VertRefresh 48-85
146
+EndSection
147
+```
148
+1. /etc/X11/xorg.conf の SubSection "Display" にモニタがサポートしている解像度を追加する。
149
+```
150
+Section "Screen"
151
+ Identifier "Screen0"
152
+ Device "Card0"
153
+ Monitor "Monitor0"
154
+ SubSection "Display"
155
+ Viewport 0 0
156
+ Depth 1
157
+ EndSubSection
158
+(中略)
159
+ SubSection "Display"
160
+ Viewport 0 0
161
+ Depth 16
162
+ Modes "1280x1024" "1024x768" "800x600"
163
+ EndSubSection
164
+ SubSection "Display"
165
+ Viewport 0 0
166
+ Depth 24
167
+ Modes "1280x1024" "1024x768" "800x600"
168
+ EndSubSection
169
+EndSection
170
+```
171
+1. /etc/inittab を編集し、Run Level を 3 から 5 に戻す。
172
+1. Reboot
173
+
174
+## nouveau ドライバ障害
175
+- 共有ライブラリが正しくインストールされず、X の画面が映らない。
176
+```
177
+# grep "(EE)" /var/log/Xorg.0.log
178
+(EE) AIGLX error: dlopen of /usr/lib64/dri/nouveau_dri.so failed (/usr/lib64/dri/nouveau_dri.so: cannot open shared object file: No such file or directory)
179
+(EE) AIGLX: reverting to software rendering
180
+```
181
+- nouveau ドライバをアンインストールし、ELRepo から nVidia ドライバをインストールする。
182
+```
183
+# yum erase xorg-x11-drv-nouveau
184
+# yum install nvidia-detect
185
+# yum install $(nvidia-detect)
186
+```
187
+- 上記「Out of Range」と同様に xorg.conf を更新する。<br />
188
+「Section "Device"」の「Driver "nv"」が「Driver "nvidia"」になっていれば成功。
189
+- /etc/modprobe.d/blacklist.conf に「blacklist nouveau」を追加する必要があるかも。
190
+
191
+# SELinux
192
+- [[Linux/SELinux]]参照。
193
+
194
+# リポジトリ追加
195
+- yum-plugin-priorities のインストール
196
+```
197
+# yum -y install yum-plugin-priorities
198
+```
199
+- /etc/yum.repos.d/CentOS-Base.repo<br />
200
+標準リポジトリを優先するため、「priority=1」を追加。
201
+```
202
+[base]
203
+name=CentOS-$releasever - Base
204
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
205
+#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
206
+gpgcheck=1
207
+gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
208
+priority=1
209
+
210
+#released updates
211
+[updates]
212
+name=CentOS-$releasever - Updates
213
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
214
+#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
215
+gpgcheck=1
216
+gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
217
+priority=1
218
+
219
+#additional packages that may be useful
220
+[extras]
221
+name=CentOS-$releasever - Extras
222
+mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
223
+#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
224
+gpgcheck=1
225
+gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
226
+priority=1
227
+```
228
+- EPELリポジトリのインストール<br />
229
+最新版を確認すること。<br />
230
+http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/
231
+```
232
+# rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
233
+# yum -y update epel-release
234
+```
235
+- RPMforgeリポジトリのインストール<br />
236
+最新版を確認すること。<br />
237
+http://pkgs.repoforge.org/rpmforge-release/
238
+```
239
+# rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
240
+# yum -y update rpmforge-release
241
+```
242
+- Adobe リポジトリのインストール
243
+```
244
+# rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
245
+# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
246
+```
247
+ - Flash Player のインストール
248
+```
249
+# yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl
250
+```
251
+- ELRepo のインストール<br />
252
+http://elrepo.org/
253
+```
254
+# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
255
+# rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm
256
+```
257
+ - nVidia ドライバの検出とインストール<br />
258
+[nvidia-detect](http://elrepo.org/tiki/nvidia-detect)
259
+```
260
+# yum install nvidia-detect
261
+# yum install $(nvidia-detect)
262
+```
263
+
264
+- [EPELリポジトリ導入(EPEL) - CentOSで自宅サーバー構築](http://centossrv.com/epel.shtml)
265
+- [RPMforgeリポジトリ導入(RPMforge) - CentOSで自宅サーバー構築](http://centossrv.com/rpmforge.shtml)
266
+- [Adobe Flash Player 11.2 on Fedora 19/18, CentOS/RHEL 6.4/5.9](http://www.if-not-true-then-false.com/2010/install-adobe-flash-player-10-on-fedora-centos-red-hat-rhel/)
267
+
268
+# fail2ban
269
+- インストール (epel リポジトリ)
270
+```
271
+# yum install fail2ban jwhois
272
+```
273
+- /etc/fail2ban/jail.conf<br />
274
+「example.com」を自ドメインに変更。
275
+```
276
+vi で一括置換
277
+:%s/you@example\.com/root@TakeAsh.net/g
278
+:%s/example\.com/svr1.TakeAsh.net/g
279
+```
280
+必要なら ssh 以外についても「enabled = true」にする。
281
+```
282
+[ssh-iptables]
283
+enabled = true
284
+filter = sshd
285
+action = iptables[name=SSH, port=ssh, protocol=tcp]
286
+ sendmail-whois[name=SSH, dest=root, sender=fail2ban@example.com]
287
+logpath = /var/log/secure
288
+maxretry = 5
289
+```
290
+「アクセス禁止時間」は「bantime」で指定。(秒単位)
291
+```
292
+# "bantime" is the number of seconds that a host is banned.
293
+bantime = 3600
294
+```
295
+- サービス設定
296
+```
297
+# chkconfig --list fail2ban
298
+# chkconfig fail2ban on
299
+# chkconfig --list fail2ban
300
+# service fail2ban start
301
+```
302
+
303
+# tripwire
304
+## インストール (EPELリポジトリ)
305
+```
306
+# yum install tripwire
307
+# tripwire-setup-keyfiles
308
+```
309
+
310
+## Suckit誤検知
311
+- エラーメッセージ
312
+```
313
+for Suckit rootkit... Warning: /sbin/init INFECTED
314
+```
315
+- 原因<br />
316
+upstart パッケージの更新により、/sbin/init のメモリマップに「(deleted)」が付加される。
317
+- 改竄されていないことの確認<br />
318
+下記を実行して何も表示されなければ、パッケージと実行ファイルとの差は無い。
319
+```
320
+# rpm -V `rpm -qf /sbin/init`
321
+```
322
+- /usr/lib64/chkrootkit-0.49/chkrootkit
323
+```
324
+--- chkrootkit.2014-02-26 2014-02-26 02:51:45.000000000 +0900
325
++++ chkrootkit_Suckit_patched 2014-03-18 09:21:41.458943399 +0900
326
+@@ -983,7 +983,10 @@
327
+ if [ ${SYSTEM} != "HP-UX" ] && ( ${strings} ${ROOTDIR}sbin/init | ${egrep} HOME || \
328
+ cat ${ROOTDIR}/proc/1/maps | ${egrep} "init." ) >/dev/null 2>&1
329
+ then
330
+- echo "Warning: ${ROOTDIR}sbin/init INFECTED"
331
++ if ! rpm -V `rpm -qf /sbin/init` >/dev/null 2>&1;
332
++ then
333
++ echo "Warning: ${ROOTDIR}sbin/init INFECTED"
334
++ fi
335
+ else
336
+ if [ -d ${ROOTDIR}/dev/.golf ]; then
337
+ echo "Warning: Suspect directory ${ROOTDIR}dev/.golf"
338
+```
339
+- [chkrootkit のSuckit誤検知の修正](http://vogel.at.webry.info/201306/article_22.html) @ [パソコン鳥のブログ](http://vogel.at.webry.info/)
340
+
341
+# vsftpd
342
+- vsftpd は chroot 下では、シンボリックリンクを辿れない。
343
+- 「mount --bind」なら chroot 下でも動作する(rebootすると設定が失われる)。
344
+```
345
+# mount --bind /var/www/html/somefolder /home/user1/somefolder
346
+```
347
+- /etc/fstab で設定すると、reboot しても設定が失われない。
348
+```
349
+/var/www/html/somefolder /home/user1/somefolder none bind 0 0
350
+```
351
+
352
+- [vsftpdのログに日本語を表示するKIYO* to Works - KIYO* to Works](http://www.k2w.jp/expression-japanese-on-log-of-vsftpd/)
353
+
354
+# lftp
355
+- FTP client
356
+- インストール
357
+```
358
+# yum install lftp
359
+```
360
+
361
+- [LFTP - sophisticated file transfer program](https://lftp.yar.ru/)
362
+
363
+# ClamAV
364
+- [アンチウィルスソフト導入(Clam AntiVirus)](http://centossrv.com/clamav.shtml) @ [CentOSで自宅サーバー構築](http://centossrv.com/)
365
+- [clamscanのオプション](http://clamav-jp.sourceforge.jp/jdoc/clamav.html#c4.1.1) @ [Clam Antivirusに関するメモ](http://clamav-jp.sourceforge.jp/jdoc/clamav.html)
366
+- 検出した感染ファイルを削除ではなく隔離するには、「--remove」ではなく「--move=DIRECTORY」オプションを使用する。
367
+- ログファイルから検出と隔離の両方を grep する。
368
+ - /etc/cron.daily/clamscan
369
+```
370
+grep -e "FOUND$" -e "moved to '[^']\+'$" $CLAMSCANTMP
371
+```
372
+
373
+- 隔離されたファイルを元の場所に戻す bash スクリプトを出力する perl スクリプト<br />
374
+ファイルのオーナーは root に変わっちゃってるけど、これはどうしたもんか。<br />
375
+[letUnjail.zip](letUnjail.zip)
376
+```perl
377
+#!/usr/bin/perl
378
+# ClamAV で隔離されたファイルを元に戻す bash スクリプトを出力する。
379
+
380
+use strict;
381
+use warnings;
382
+use utf8;
383
+use Encode;
384
+
385
+my $charsetConsole = 'UTF-8';
386
+#my $charsetConsole = 'CP932';
387
+my $charsetFile = 'UTF-8';
388
+
389
+binmode( STDIN, ":encoding($charsetConsole)" );
390
+binmode( STDOUT, ":encoding($charsetConsole)" );
391
+binmode( STDERR, ":encoding($charsetConsole)" );
392
+
393
+my $fileNameIn = shift or die("usage: letUnjail.pl <jail.log>\n");
394
+my $fileNameOut = 'unjail.sh';
395
+
396
+open( my $fhIn, '<', $fileNameIn ) or die( "$fileNameIn: $!\n" );
397
+binmode( $fhIn, ":encoding($charsetFile)" );
398
+
399
+open( my $fhOut, '>', $fileNameOut ) or die( "$fileNameOut: $!\n" );
400
+binmode( $fhOut, ":encoding($charsetFile)" );
401
+print $fhOut "#!/bin/bash\n\n";
402
+
403
+my %virusNames = ();
404
+while( my $line = <$fhIn> ){
405
+ if ( $line =~ m{^([\s\S]+):\s([\s\S]+)\sFOUND\s*$} ){
406
+ $virusNames{$1} = $2;
407
+ } elsif ( $line =~ m{^([\s\S]+):\smoved\sto\s'([\s\S]+)'\s*$} ){
408
+ if ( my $virusName = $virusNames{$1} ){
409
+ print $fhOut "# $virusName\n";
410
+ }
411
+ print $fhOut "mv -v '$2' '$1'\n";
412
+ }
413
+}
414
+
415
+close( $fhIn );
416
+close( $fhOut );
417
+
418
+chmod( 0700, $fileNameOut );
419
+
420
+# EOF
421
+```
422
+
423
+- データベースとログのオーナが一致していないと正常に更新されない。
424
+ - エラーメッセージ
425
+ - その1
426
+```
427
+/etc/cron.daily/clamscan:
428
+
429
+ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
430
+/etc/cron.daily/freshclam:
431
+
432
+ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).
433
+ERROR: Can't open /var/log/clamav/freshclam.log in append mode (check permissions!).
434
+```
435
+ - その2
436
+```
437
+No updates detected in the log for the freshclam daemon (the ClamAV update process).
438
+If the freshclam daemon is not running, you may need to restart it.
439
+Other options:
440
+
441
+A. If you no longer wish to run freshclam, deleting the log file
442
+ (default is freshclam.log) will suppress this error message.
443
+
444
+B. If you use a different log file, update the appropriate configuration file.
445
+ For example:
446
+ echo "LogFile = log_file" >> /etc/logwatch/conf/logfiles/clam-update.conf
447
+ where log_file is the filename of the freshclam log file.
448
+
449
+C. If you are logging using syslog, you need to indicate that your log file uses the syslog format.
450
+ For example:
451
+ echo "*OnlyService = freshclam" >> /etc/logwatch/conf/logfiles/clam-update.conf
452
+ echo "*RemoveHeaders" >> /etc/logwatch/conf/logfiles/clam-update.conf
453
+```
454
+ - その3
455
+```
456
+Clamd was NOT notified: Can't connect to clamd through /var/run/clamav/clamd.sock
457
+LOCAL: Socket file /var/run/clamav/clamd.sock could not be bound: Permission denied
458
+Can't unlink the socket file /var/run/clamav/clamd.sock
459
+LOCAL: Socket file /var/run/clamav/clamd.sock could not be removed: Permission denied
460
+```
461
+ - /etc/clamd.conf
462
+```
463
+User clamav
464
+```
465
+ - /etc/freshclam.conf
466
+```
467
+DatabaseOwner clamav
468
+```
469
+ - /etc/logrotate.d/clamav
470
+```
471
+create 644 clamav clamav
472
+```
473
+ - /etc/logrotate.d/freshclam
474
+```
475
+create 644 clamav clamav
476
+```
477
+ - /var/clamav/ <br />
478
+/var/lib/clamav/ <br />
479
+/var/log/clamav/ <br />
480
+/var/run/clamav/
481
+| owner | clamav |
482
+| --- | --- |
483
+| group | clamav |
484
+ - &#x7e;/fixClamavOwner.sh
485
+```bash
486
+#!/bin/bash
487
+chown clamav. -R /var/clamav/ /var/lib/clamav/ /var/log/clamav/ /var/run/clamav/
488
+```
489
+
490
+# 追加パッケージ
491
+## ベース, 開発環境
492
+```
493
+# yum -y groupinstall "Base" "Development tools"
494
+```
495
+
496
+## Perl/CGI
497
+```
498
+# yum install gcc gcc-cpp gcc-c++
499
+# yum install openssl-devel mysql-devel expat-devel
500
+# yum install perl-YAML-Syck perl-libwww-perl perl-CPAN mod_perl
501
+```
502
+
503
+## FontForge
504
+- [FontForge](http://sourceforge.net/projects/fontforge/)
505
+- FontForge 自体は yum でインストール可能だがバージョンが古い。
506
+- ソースから configure する際、X11 の開発環境がないと警告が表示される。
507
+```
508
+# tar jxvf fontforge_*.tar.bz2
509
+# cd fontforge-
510
+# ./configure
511
+...
512
+*******************************************************************
513
+* This version of fontforge will only run scripts. No X libraries *
514
+* (or X include files or some such) were found so there is NO user*
515
+* interface!!!!! If you want a UI try installing X11 on your *
516
+* system. *
517
+* Caveat: You will probably need to install two packages, the *
518
+* base X11 package and the developer SDK package *
519
+*******************************************************************
520
+```
521
+- GUI有りでコンパイルするには X11 の開発環境をインストールする。
522
+```
523
+# yum install libX11-devel libICE-devel libSM-devel libXi-devel freetype-devel libxml2-devel gettext-devel
524
+# yum install gcc-gfortran python-devel libpng-devel libjpeg-devel libtiff-devel libspiro-devel
525
+```
526
+- コンパイル & インストール
527
+```
528
+# ./configure
529
+# make
530
+# make install
531
+```
532
+- [cidmaps.tgz](http://fontforge.sourceforge.net/cidmaps.tgz)をダウンロードしインストールする。
533
+```
534
+# cd /usr/local/share/fontforge/
535
+# wget http://fontforge.sourceforge.net/cidmaps.tgz
536
+# tar xzvf cidmaps.tgz
537
+```
538
+- serif フォントのインストール
539
+```
540
+# yum install liberation-serif-fonts
541
+```
542
+- gnome メニューに追加<br />
543
+/usr/share/applications/fontforge.desktop
544
+```
545
+[Desktop Entry]
546
+Name=FontForge
547
+Comment=An outline font editor
548
+Exec=fontforge
549
+Icon=fontforge
550
+Terminal=false
551
+Type=Application
552
+Categories=Application;Graphics;X-Fedora;
553
+Encoding=UTF-8
554
+MimeType=application/vnd.font-fontforge-sfd;
555
+X-Desktop-File-Install-Version=0.15
556
+```
557
+ - [@IT:GNOMEメニューを編集するための基礎知識](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/714gnomemenu.html)
558
+
559
+# logwatch
560
+## インストール
561
+```
562
+# yum install logwatch
563
+```
564
+- [logwatchのインストール](http://ja.528p.com/linux/centos6/SN006-logwatch.html)
565
+
566
+## メールの文字化け対応
567
+- /usr/share/logwatch/scripts/logwatch.pl
568
+```
569
+--- logwatch_1.pl 2012-05-10 21:13:58.150740082 +0900
570
++++ logwatch.pl 2012-05-10 21:15:29.666734718 +0900
571
+@@ -1050,12 +1050,12 @@
572
+ if ( $Config{encode} == 1 ) {
573
+ $out_mime .= "Content-transfer-encoding: base64\n";
574
+ } else {
575
+- $out_mime .= "Content-Transfer-Encoding: 7bit\n";
576
++ $out_mime .= "Content-Transfer-Encoding: 8bit\n";
577
+ }
578
+ if ( $outtype_html ) {
579
+- $out_mime .= "Content-Type: text/html; charset=\"iso-8859-1\"\n\n";
580
++ $out_mime .= "Content-Type: text/html; charset=\"utf-8\"\n\n";
581
+ } else {
582
+- $out_mime .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n";
583
++ $out_mime .= "Content-Type: text/plain; charset=\"utf-8\"\n\n";
584
+ }
585
+
586
+ if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
587
+```
588
+
589
+## sendmail 失敗
590
+- エラーメッセージ
591
+```
592
+Can't exec "sendmail": No such file or directory at /usr/sbin/logwatch line 1040, <TESTFILE> line 2.
593
+Can't execute sendmail -t: No such file or directory
594
+```
595
+- /etc/logwatch/conf/logwatch.conf
596
+```
597
+mailer = "/usr/sbin/sendmail -t"
598
+```
599
+- [へっぽこサーバ管理もろもろ: Can't exec "sendmail" - logwatchで](http://serverkanri.blogspot.jp/2011/05/cant-exec-sendmail-logwatch.html)
600
+
601
+# Log Rotate
602
+## duplicate log entry
603
+- エラーメッセージ
604
+```
605
+/etc/cron.daily/logrotate:
606
+error: freshclam duplicate log entry for /var/log/clamav/freshclam.log
607
+error: found error in /var/log/clamav/freshclam.log , skipping
608
+```
609
+- /etc/logrotate.d/ 内で複数の設定から同一のログファイルを更新しようとしている。別ファイルに割り当てるように変更する。
610
+
611
+# vnc
612
+- [[Linux/VNC]] へ移動。
613
+
614
+# GNOME
615
+
616
+## キーボード設定
617
+- キーボードを英語設定から日本語設定に切り替えられない。
618
+- /home/(ユーザ名)/.gconf/desktop/gnome/peripherals/keyboard/kbd/%gconf.xml <br />
619
+「model」の値を「pc105」から「jp106」に設定する。
620
+
621
+# 自動起動するアプリ
622
+- 「自動起動するアプリの設定」で「PackageKit 更新アプレット」にチェックが入っていると、GDMからログインする毎に root パスワードを求められるのでチェックを外す。
623
+- 「システム - 設定 - 自動起動するアプリ - PackageKit 更新アプレット」
624
+
625
+# BIND
626
+## root hint 更新スクリプト
627
+- /etc/cron.monthly/named.root_update
628
+```bash
629
+#!/bin/bash
630
+
631
+new=`mktemp`
632
+errors=`mktemp`
633
+roothint=/var/named/chroot/var/named/named.ca
634
+
635
+dig . ns @198.41.0.4 +bufsize=1024 > $new 2> $errors
636
+
637
+if [ $? -eq 0 ]; then
638
+ sort_new=`mktemp`
639
+ sort_old=`mktemp`
640
+ diff_out=`mktemp`
641
+ sort $new > $sort_new
642
+ sort $roothint > $sort_old
643
+ diff -u --ignore-matching-lines=^\; $sort_old $sort_new > $diff_out
644
+ if [ $? -ne 0 ]; then
645
+ (
646
+ echo '-------------------- old named.root --------------------'
647
+ cat $roothint
648
+ echo '-------------------- new named.root --------------------'
649
+ cat $new
650
+ echo '---------------------- difference ----------------------'
651
+ cat $diff_out
652
+ ) | mail -s 'named.root updated' root
653
+ cp -f $new $roothint
654
+ chown named. $roothint
655
+ chmod 644 $roothint
656
+ service named restart > /dev/null
657
+ fi
658
+ rm -f $sort_new $sort_old $diff_out
659
+else
660
+ cat $errors | mail -s 'named.root update check error' root
661
+fi
662
+rm -f $new $errors
663
+```
664
+- [DNSサーバー構築(BIND)](http://centossrv.com/bind.shtml)との差
665
+ - root hint のパスを変数化。
666
+ - diff を unified 形式に、From と To を入れ替え。
667
+ - service コマンド。
668
+
669
+## ゾーン転送
670
+- /var/named/chroot/etc/named.conf
671
+ - 許可
672
+```
673
+allow-transfer {
674
+ host1;
675
+ host2;
676
+};
677
+```
678
+ - 禁止
679
+```
680
+allow-transfer { none; };
681
+```
682
+
683
+- ゾーン転送動作確認(slave側で読み込めるかどうか確認する)
684
+ - Linuxの場合
685
+```
686
+# dig @<masterのホスト名> <確認したいドメイン名> axfr
687
+```
688
+ - Windowsの場合
689
+```
690
+> nslookup
691
+> server <masterのホスト名>
692
+> ls -d <確認したいドメイン名>
693
+```
694
+
695
+## 監視スクリプト
696
+- named デーモンを監視し、必要ならば再起動する。
697
+ - bind ソースに含まれる nanny.pl を使用する。
698
+ - [nanny_tak.zip](nanny_tak.zip) 再起動時に root 宛にメールする機能を追加。
699
+
700
+## エラー対応
701
+- 外部ドメインの名前解決できない場合の対策(検索結果のキャッシュに失敗している)
702
+ - SELinuxの「Allow BIND to write the master zone files. Generally this is used for dynamic DNS.(named_write_master_zones)」にチェックを入れる。
703
+```
704
+# setsebool -P named_write_master_zones 1
705
+```
706
+- 「named: the working directory is not writable」対応
707
+```
708
+# chmod 770 /var/named/chroot/var/named
709
+```
710
+
711
+- dnssec エラー対応
712
+```
713
+dlv.isc.org SOA: no valid signature found
714
+dlv.isc.org SOA: got insecure response; parent indicates it should be secure
715
+```
716
+ - 原因: forwarders で指定した DNS が dnssec に対応していない。
717
+ - 確認: dig コマンドを実行し、ANSWER SECTION に RRSIG レコードが含まれていることを確認する。
718
+```
719
+# dig +dnssec dlv.isc.org @(DNSのIPアドレス)
720
+```
721
+&#x20;
722
+```
723
+# dig +dnssec dlv.isc.org @8.8.8.8
724
+(省略)
725
+;; ANSWER SECTION:
726
+dlv.isc.org. 102 IN A 149.20.16.8
727
+dlv.isc.org. 102 IN RRSIG A 5 3 300 2012...
728
+(省略)
729
+```
730
+ - 対策: forwarders には [Google Public DNS](http://code.google.com/intl/ja/speed/public-dns/) など dnssec に対応した DNS のみを指定する。
731
+
732
+- empty zones 警告対応
733
+```
734
+Warning: view LAN: 'empty-zones-enable/disable-empty-zone' not set: disabling RFC 1918 empty zones: 1 Time(s)
735
+```
736
+ - 原因: empty-zones-enable が指定されていない。
737
+ - 対策: empty-zones-enable を追加。
738
+```
739
+empty-zones-enable yes;
740
+```
741
+ - [Automatic empty zones (including RFC 1918 prefixes) - Internet Systems Consortium Knowledge Base](https://deepthought.isc.org/article/AA-00800/0/Automatic-empty-zones-including-RFC-1918-prefixes.html)
742
+
743
+## リンク
744
+- [DNSサーバー構築(BIND)](http://centossrv.com/bind.shtml) @ [CentOSで自宅サーバー構築](http://centossrv.com/)
745
+- [実用 BIND 9で作るDNSサーバ](http://www.atmarkit.co.jp/flinux/index/indexfiles/index-linux.html#bind9)
746
+- [Internet Systems Consortium](http://www.isc.org/)
747
+- [オープンリゾルバ確認サイト](http://www.openresolver.jp/)
748
+ - [オープンリゾルバ確認サイト公開のお知らせ](https://www.jpcert.or.jp/pr/2013/pr130002.html)
749
+
750
+# OpenVPN
751
+## Bonding
752
+- 複数の NIC で冗長化を行っている状態で proto udp を指定すると「Replay-window backtrack occurred [x]」が大量に発生し接続が切れてしまう。
753
+ - ボンディングモードを「0(round-robin)」ではなく「6(Active Load Balancing)」に変更する。
754
+- [[NICの冗長化>Linux/NIC_Bonding]]
755
+
756
+## Tunneling
757
+- OpenVPN パッケージに更新があった場合は、トンネル設定を再度行う必要がある。
758
+ - /etc/rc.d/init.d/openvpn<br />
759
+行頭の # を削除し、有効化する。
760
+```
761
+echo 1 > /proc/sys/net/ipv4/ip_forward
762
+```
763
+
764
+- 仮想ネットワーク上のパケットを VPN サーバに転送するために
765
+ - スタティックルーティングを設定する必要がある。
766
+| 宛先IPアドレス | 10.8.0.0/24 |
767
+| --- | --- |
768
+| ゲートウェイ | VPN サーバの IP アドレス |
769
+ - ファイアウォールで、同一インターフェース内のパケット転送を許可しなければならない場合がある。<br />
770
+例) VPN サーバが DMZ に配置されている場合
771
+| アクション | 許可 |
772
+| --- | --- |
773
+| 受信インターフェース | DMZ |
774
+| 送信インターフェース | DMZ |
775
+| 送信元IPアドレス | すべて |
776
+| 宛先IPアドレス | すべて |
777
+| プロトコル | 全て |
778
+| ポート | 全て |
779
+
780
+# Apache
781
+- [[Linux/Apache]]へ移動。
... ...
\ No newline at end of file
Linux/Install/CentOS7.md
... ...
@@ -0,0 +1,226 @@
1
+[[_TOC_]]
2
+
3
+# ホスト名設定
4
+- hostnamectl コマンドで設定する。
5
+```
6
+# hostnamectl set-hostname <ホスト名>
7
+```
8
+
9
+# ネットワーク設定
10
+- nmtui/nmcli コマンドで設定する。
11
+- デバイス確認
12
+```
13
+# nmcli dev
14
+```
15
+- デバイス詳細確認
16
+```
17
+# nmcli dev show <デバイス名>
18
+```
19
+- 接続確認
20
+```
21
+# nmcli con
22
+```
23
+- 接続詳細確認
24
+```
25
+# nmcli con show <接続名>
26
+```
27
+
28
+# パッケージ管理システム更新
29
+- インストール
30
+```
31
+# yum -y update
32
+# yum -y install yum-cron
33
+```
34
+- /etc/yum/yum-cron.conf
35
+```
36
+#apply_updates = no
37
+apply_updates = yes
38
+```
39
+- サービス起動 & 自動起動サービス登録
40
+```
41
+# systemctl start yum-cron
42
+# systemctl enable yum-cron
43
+```
44
+
45
+# リポジトリ追加
46
+- [EPEL](https://fedoraproject.org/wiki/EPEL/ja) の追加。<br />
47
+libmp4v2(mp4tags)
48
+```
49
+# yum install epel-release
50
+```
51
+
52
+- [Software Collections](https://www.softwarecollections.org/)<br />
53
+https://wiki.centos.org/SpecialInterestGroup/SCLo <br />
54
+プライオリティ=10 に設定
55
+```
56
+# yum install centos-release-scl centos-release-scl-rh
57
+# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl.repo
58
+# sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
59
+```
60
+
61
+- [CentOS 7 : 初期設定 : リポジトリ追加 : Server World](https://www.server-world.info/query?os=CentOS_7&p=initial_conf&f=6)
62
+
63
+- [Nux Dextop](http://li.nux.ro/repos.html)<br />
64
+デスクトップおよびマルチメディア関連のリポジトリ。ffmpeg, rtmpdump, phantomjs。
65
+```
66
+# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
67
+# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
68
+```
69
+
70
+# グループインストール
71
+- 使用可能なグループ一覧<br />
72
+LANG=en_US.UTF-8 下で行うと英語表記のグループ名が得られる。<br />
73
+非表示のグループも表示させるには hidden オプションを追加する。
74
+```
75
+# yum grouplist [hidden]
76
+```
77
+- グループ名(抜粋, CentOS 7.7)
78
+| 英語 | 日本語 |
79
+| --- | --- |
80
+| Infrastructure Server | インフラストラクチャサーバー |
81
+| Basic Web Server | ベーシック Web サーバー |
82
+| File and Print Server | ファイルとプリントサーバー |
83
+| Virtualization Host | 仮想化ホスト |
84
+| Server with GUI | サーバー (GUI 使用) |
85
+| GNOME Desktop | GNOME Desktop |
86
+| Desktop | デスクトップ |
87
+| Desktop Platform | デスクトップ環境 |
88
+| Desktop Platform Development | デスクトップ環境の開発環境 |
89
+| Virtualization | 仮想化 |
90
+| Development Tools | 開発ツール |
91
+| Fonts | フォント |
92
+| Input Methods | 入力メソッド |
93
+- インストール
94
+```
95
+# yum groupinstall "GNOME Desktop" "Server with GUI" "File and Print Server"
96
+```
97
+
98
+# その他のインストール
99
+```
100
+# yum install mailx logwatch setroubleshoot-server
101
+```
102
+
103
+# 時刻同期設定
104
+- インストール
105
+```
106
+# yum install chrony
107
+```
108
+- /etc/chrony.conf
109
+```
110
+(既存の server 行はコメントアウト)
111
+server ntp.nict.jp iburst
112
+server ntp.jst.mfeed.ad.jp iburst
113
+
114
+#allow 192.168/16
115
+allow 192.168/16
116
+```
117
+- サービス起動 & 自動起動サービス登録
118
+```
119
+# systemctl start chronyd
120
+# systemctl enable chronyd
121
+```
122
+
123
+# root 宛てメール転送
124
+- /etc/aliases に root の転送先メールアドレスを追加。
125
+```
126
+root: Actual.User@example.com
127
+```
128
+- 転送設定反映。
129
+```
130
+# newaliases
131
+```
132
+- 転送テスト
133
+```
134
+# date | mail -s "root メール転送テスト" root
135
+```
136
+
137
+# Apache
138
+```
139
+# yum install httpd
140
+# systemctl start httpd
141
+# systemctl enable httpd
142
+# systemctl is-enabled httpd
143
+```
144
+- firewall 設定
145
+```
146
+# firewall-cmd --get-active-zones (現在のゾーンの確認)
147
+# firewall-cmd --permanent --zone=public --add-service=http (active なゾーンに合わせること)
148
+# firewall-cmd --reload
149
+```
150
+
151
+# 起動メッセージ表示
152
+- /etc/default/grub<br />
153
+「rhgb quiet」を削除。
154
+```
155
+#GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet"
156
+GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto"
157
+```
158
+- grub.cfg を更新。
159
+```
160
+# grub2-mkconfig -o /boot/grub2/grub.cfg
161
+```
162
+
163
+# CUI/GUI 切り替え
164
+- 現在の設定の確認
165
+```
166
+# systemctl get-default
167
+```
168
+- CUI で起動 (runlevel 3 相当)
169
+```
170
+# systemctl set-default multi-user.target
171
+```
172
+- GUI で起動 (runlevel 5 相当)
173
+```
174
+# systemctl set-default graphical.target
175
+```
176
+
177
+# 日本語入力 (かな漢字変換)
178
+- 「アプリケーション - システムツール - 設定 - 地域と言語 - 入力ソース」で「日本語」「日本語 (かな漢字)」の2つを選択する。
179
+- 「日本語 (かな漢字)」だけにするとキーボードが英語配列になる? (iBus かな漢字 1.5.18)
180
+
181
+# ファイアウォール設定
182
+- ファイアウォール動作状況確認
183
+```
184
+# systemctl status firewalld
185
+```
186
+
187
+- ファイアウォール再起動
188
+```
189
+# systemctl restart firewalld
190
+```
191
+
192
+- デフォルトゾーン確認
193
+```
194
+# firewall-cmd --list-all
195
+```
196
+
197
+- 定義されているサービス一覧の表示
198
+```
199
+# firewall-cmd --get-services
200
+```
201
+
202
+- デフォルトゾーンで許可されているサービスの確認
203
+```
204
+# firewall-cmd --list-service
205
+```
206
+
207
+- サービスの追加(samba)<br />
208
+firewalld を再起動/設定反映するまで反映されない。
209
+```
210
+# firewall-cmd --add-service=samba --permanent
211
+```
212
+
213
+- デフォルトゾーンで許可されているポートの確認
214
+```
215
+# firewall-cmd --list-port
216
+```
217
+
218
+- ポートの追加<br />
219
+firewalld を再起動/設定反映するまで反映されない。
220
+```
221
+# firewall-cmd --add-port=30001/tcp --permanent
222
+```
223
+
224
+- 設定反映
225
+```
226
+# firewall-cmd --reload
... ...
\ No newline at end of file
Linux/Install/Fedora13.md
... ...
@@ -0,0 +1,169 @@
1
+# Fedora 13
2
+[[_TOC_]]
3
+
4
+## ネットワークの設定
5
+- /etc/sysconfig/network
6
+```
7
+NETWORKING=yes
8
+HOSTNAME=srv1.TakeAsh.net
9
+DOMAINNAME=TakeAsh.net
10
+GATEWAY=192.168.0.1
11
+```
12
+
13
+## yumの設定
14
+### 自動的に近いミラーを参照するようにする
15
+```
16
+# yum -y install yum-plugin-fastestmirror
17
+```
18
+
19
+### パッケージのアップデートと自動更新の設定
20
+```
21
+# yum install yum-cron
22
+# service yum-cron start
23
+# chkconfig --list yum-cron
24
+# chkconfig yum-cron on
25
+# chkconfig --list yum-cron
26
+```
27
+
28
+## vncの設定
29
+vnc serverのインストール
30
+```
31
+# yum install vnc-ltsp-config
32
+```
33
+
34
+### gdmの設定
35
+- /etc/gdm/custom.conf (抜粋)
36
+```
37
+[xdmcp]
38
+Enable=true
39
+
40
+[greeter]
41
+IncludeAll=false
42
+```
43
+
44
+### xinet.d
45
+- /etc/xinetd.d/vncts (抜粋)
46
+```
47
+service vnc-1024x768x16
48
+{
49
+ disable = no
50
+ type = UNLISTED
51
+ port = 5900
52
+ socket_type = stream
53
+ wait = no
54
+ only_from = 192.168.0.0/24 10.8.0.0/24
55
+ user = nobody
56
+ group = tty
57
+ server = /usr/bin/vncts
58
+ server_args = -geometry 1024x768 -depth 16
59
+}
60
+```
61
+
62
+- xinetd の再起動
63
+```
64
+# service xinetd restart
65
+```
66
+
67
+### ファイアウォール設定
68
+ 1. 「システム/管理/ファイアーウォール」を起動。
69
+ 1. 「その他のポート」を選択。
70
+ 1. 「追加」をクリック。
71
+ 1. 「5900/TCP/vnc-server」を選択。
72
+ 1. 「OK」をクリック。
73
+ 1. 「適用」をクリック。
74
+
75
+### リンク
76
+- [Fedora 12で xinetd, VNC, &#x58;DMCP (手順編)](http://blog.glatts.com/blog/imai/?p=639)
77
+
78
+## Postfixの設定
79
+- 自ドメイン内に主メールサーバがある場合、mydestination には $mydomain を含めない。
80
+- 転送設定を反映させるために postalias を実行した後、サービスを再起動する。
81
+```
82
+# postalias hash:/etc/aliases
83
+# service postfix restart
84
+```
85
+
86
+### リンク
87
+- [メールサーバー構築](http://fedorasrv.com/postfix.shtml)
88
+- [Postfixのメール転送の設定](http://chibi.name/fedora/server/postfixopt.shtml)
89
+
90
+## Sambaの設定
91
+
92
+### インストール
93
+```
94
+# yum install samba
95
+```
96
+
97
+### 共有用フォルダ
98
+```
99
+# cd /home
100
+# mkdir Shared
101
+# chown nobody:nobody Shared
102
+# chmod 777 Shared
103
+```
104
+
105
+### 設定
106
+- /etc/samba/smb.conf (抜粋)
107
+```
108
+[global]
109
+ dos charset = CP932
110
+ unix charset = UTF-8
111
+ display charset = UTF-8
112
+
113
+ workgroup = WORKGROUP
114
+
115
+ hosts allow = 127. 192.168.0. 10.8.0.
116
+
117
+ security = user
118
+
119
+[homes]
120
+ browseable = no
121
+ writable = yes
122
+ valid users = %U
123
+
124
+[Shared]
125
+ path = /home/Shared
126
+ read only = no
127
+ browseable = yes
128
+ valid users = {アクセスを許可するユーザのリスト}
129
+ share modes = yes
130
+ dos filetimes = yes
131
+```
132
+
133
+### サービス設定
134
+```
135
+# chkconfig --list smb
136
+# chkconfig smb on
137
+# chkconfig --list smb
138
+# service smb restart
139
+# chkconfig --list nmb
140
+# chkconfig nmb on
141
+# chkconfig --list nmb
142
+# service nmb restart
143
+```
144
+
145
+### ファイアウォール設定
146
+ 1. 「システム/管理/ファイアーウォール」を起動。
147
+ 1. 「信頼したサービス」を選択。
148
+ 1. 「Samba」「Sambaクライアント」にチェックを入れる。
149
+ 1. 「OK」をクリック。
150
+ 1. 「適用」をクリック。
151
+
152
+### SELinux設定
153
+ 1. 「システム/管理/SELinux Management」を起動。
154
+ 1. rootパスワード入力。
155
+ 1. 「選択: ブーリアン値」を選択。
156
+ 1. 「Module: samba」の「Allow samba to share any file/directory read/write.」にチェックを入れる。
157
+ 1. SELinuxの変更を反映させるため、Fedoraを再起動。
158
+
159
+### リンク
160
+- [Windowsファイルサーバー構築(Samba)](http://fedorasrv.com/samba.shtml) @ [Fedoraで自宅サーバー構築](http://fedorasrv.com/)
161
+
162
+## logwatch設定
163
+- インストールされているかどうか確認
164
+```
165
+# rpm -qa | grep logwatch
166
+```
167
+- インストール
168
+```
169
+# yum install logwatch
... ...
\ No newline at end of file
Linux/Install/Fedora14.md
... ...
@@ -0,0 +1,282 @@
1
+# Fedora 14
2
+[[_TOC_]]
3
+
4
+## ネットワークの設定
5
+- /etc/sysconfig/network
6
+```
7
+NETWORKING=yes
8
+HOSTNAME=srv1.TakeAsh.net
9
+DOMAINNAME=TakeAsh.net
10
+GATEWAY=192.168.0.1
11
+```
12
+
13
+## yumの設定
14
+### 自動的に近いミラーを参照するようにする
15
+```
16
+# yum -y install yum-plugin-fastestmirror
17
+```
18
+
19
+### パッケージのアップデートと自動更新の設定
20
+```
21
+# yum install yum-cron
22
+# service yum-cron start
23
+# chkconfig --list yum-cron
24
+# chkconfig yum-cron on
25
+# chkconfig --list yum-cron
26
+```
27
+
28
+## sshの設定
29
+### ホスト側の設定
30
+- 公開鍵/秘密鍵の作成(リモートからログインしたいアカウントで作業する)
31
+ - ファイル名はそのままEnterを押す。
32
+ - passphrase はログイン時に必要となるのでメモしておく。
33
+ - 秘密鍵はUSBメモリ等漏洩しない経路でリモート側のマシンにコピーし、コピー後はホストから削除しておく。
34
+
35
+```
36
+$ ssh-keygen -t rsa
37
+```
38
+
39
+```
40
+$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
41
+$ chmod 600 ~/.ssh/authorized_keys
42
+```
43
+
44
+- /etc/ssh/sshd_config (rootで作業する)
45
+```
46
+PermitRootLogin no
47
+PermitEmptyPasswords no
48
+PasswordAuthentication no
49
+```
50
+
51
+- TeraTerm の鍵作成機能使って作った秘密鍵だと PuTTY 用に変換してもログインできなかったのは何故だろう。<br />
52
+サーバで作成した秘密鍵の方は正常にログインできたけど。
53
+
54
+### クライアント側
55
+- クライアントとして [Tera Term](http://ttssh2.sourceforge.jp/) を使う。
56
+- *.ttl に ttpmacro.exe を関連付けておくことで自動ログインできる。
57
+- このマクロを使うときは C:\Program Files\TeraTerm\ssh_keys に秘密鍵ファイルをコピーしておくこと。
58
+- ログイン時には公開鍵/秘密鍵を作成したときのパスフレーズを毎回タイプする。
59
+- root のパスワードは初回のみタイプが必要。暗号化されてファイルに記録されるので2回目以降はタイプする必要はない。
60
+- [srv1.ttl](srv1.ttl)
61
+```
62
+; sample macro of Tera Term
63
+;
64
+; File: ssh2login.ttl
65
+; Description: auto login with SSH2 protocol
66
+; Environment: generic
67
+; Update: 2004/12/4
68
+; Author: Yutaka Hirata
69
+
70
+username = 'yourname' ; ログインに使うユーザアカウント名
71
+hostname = 'srv1.TakeAsh.net'
72
+keyfile = '"C:\Program Files\TeraTerm\ssh_keys\id_rsa"' ; パスに空白を含む場合は""で括る。
73
+;pwfile = '"C:\Program Files\TeraTerm\ssh_keys\password.dat"' ; getpassword のファイル名に空白を含むことはできない?
74
+PasswordPrompt = 'パスワード:'
75
+
76
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
77
+
78
+msg = 'Enter passphrase for user '
79
+strconcat msg username
80
+passwordbox msg 'Get passphrase'
81
+
82
+msg = hostname
83
+strconcat msg ':22 /ssh /auth=publickey /user='
84
+strconcat msg username
85
+strconcat msg ' /passwd='
86
+strconcat msg inputstr
87
+strconcat msg ' /keyfile='
88
+strconcat msg keyfile
89
+connect msg
90
+
91
+wait username ;自動的にrootになりたければここから下も記述
92
+sendln 'su -'
93
+wait PasswordPrompt
94
+getpassword 'C:\Program Files\TeraTerm\ssh_keys\password.dat' 'srv1_root' PasswordROOT
95
+sendln PasswordROOT
96
+```
97
+
98
+### リンク
99
+- [Tera Term Open Source Project](http://ttssh2.sourceforge.jp/)
100
+ - [ダウンロード](http://sourceforge.jp/projects/ttssh2/releases/)
101
+ - [ヘルプ 目次](http://ttssh2.sourceforge.jp/manual/ja/)
102
+ - [MACRO Help Index](http://ttssh2.sourceforge.jp/manual/ja/macro/)
103
+ - [Tera Termマクロ活用入門(1):各種ログインを自動化する - SourceForge.JP Magazine](http://sourceforge.jp/magazine/10/01/08/0825239)
104
+- [teraterm(ssh2対応) + 公開鍵認証 - Charly's notepad](http://www.erde.co.jp/~katsu/wiki/index.php?teraterm(ssh2%C2%D0%B1%FE)%20%2B%20%B8%F8%B3%AB%B8%B0%C7%A7%BE%DA)
105
+
106
+## vncの設定
107
+vnc serverのインストール
108
+```
109
+# yum install vnc-ltsp-config tigervnc-server
110
+```
111
+- 「tigervnc-server」を明示して追加しないとXDMCPによるリモートログインができない。
112
+
113
+- http://wiki.centos.org/HowTos/VNC-Server
114
+
115
+### gdmの設定
116
+- /etc/gdm/custom.conf (抜粋)
117
+```
118
+[xdmcp]
119
+Enable=true
120
+
121
+[greeter]
122
+IncludeAll=false
123
+```
124
+
125
+### xinetd
126
+- /etc/xinetd.d/vncts (抜粋)
127
+```
128
+service vnc-1024x768x16
129
+{
130
+ disable = no
131
+ type = UNLISTED
132
+ port = 5900
133
+ socket_type = stream
134
+ wait = no
135
+ user = nobody
136
+ group = tty
137
+ server = /usr/bin/vncts
138
+ server_args = -geometry 1024x768 -depth 16
139
+ only_from = 192.168.0.0/24 10.8.0.0/24
140
+}
141
+```
142
+
143
+- xinetd の再起動
144
+```
145
+# service xinetd restart
146
+```
147
+
148
+### ファイアウォール設定
149
+ 1. 「システム/管理/ファイアーウォール」を起動。
150
+ 1. 「その他のポート」を選択。
151
+ 1. 「追加」をクリック。
152
+ 1. 「5900/TCP/vnc-server」を選択。
153
+ 1. 「OK」をクリック。
154
+ 1. 「適用」をクリック。
155
+
156
+### リンク
157
+- [Fedora 12で xinetd, VNC, &#x58;DMCP (手順編)](http://blog.glatts.com/blog/imai/?p=639)
158
+- [remote logon problem - FedoraForum.org](http://forums.fedoraforum.org/showthread.php?p=1434093)
159
+
160
+## Postfixの設定
161
+- 自ドメイン内にホストマシンとは別に主メールサーバがある場合
162
+ - myorigin は $mydomain ではなく $myhostname にする。
163
+ - mydestination には $mydomain を含めない。
164
+- 転送設定を反映させるために postalias を実行した後、サービスを再起動する。
165
+```
166
+# postalias hash:/etc/aliases
167
+# service postfix restart
168
+```
169
+
170
+### リンク
171
+- [メールサーバー構築](http://fedorasrv.com/postfix.shtml)
172
+- [Postfixのメール転送の設定](http://chibi.name/fedora/server/postfixopt.shtml)
173
+
174
+## Dovecotの設定
175
+- TLSを使わず平文パスワードで認証する場合
176
+ - /etc/dovecot/conf.d/10-auth.conf
177
+```
178
+disable_plaintext_auth = no
179
+```
180
+
181
+## Sambaの設定
182
+
183
+### インストール
184
+```
185
+# yum install samba
186
+```
187
+
188
+### 共有用フォルダ
189
+```
190
+# cd /home
191
+# mkdir Shared
192
+# chown nobody:nobody Shared
193
+# chmod 777 Shared
194
+```
195
+
196
+### 設定
197
+- /etc/samba/smb.conf (抜粋)
198
+```
199
+[global]
200
+ workgroup = WORKGROUP
201
+
202
+ hosts allow = 127. 192.168.0. 10.8.0.
203
+ wide links = yes
204
+ follow symlinks = yes
205
+ unix extensions = no
206
+
207
+ security = user
208
+
209
+[homes]
210
+ browseable = no
211
+ writable = yes
212
+ valid users = %U
213
+
214
+[Shared]
215
+ path = /home/Shared
216
+ read only = no
217
+ browseable = yes
218
+ valid users = {アクセスを許可するユーザのリスト}
219
+ share modes = yes
220
+ dos filetimes = yes
221
+```
222
+
223
+### サービス設定
224
+```
225
+# chkconfig --list smb
226
+# chkconfig smb on
227
+# chkconfig --list smb
228
+# service smb restart
229
+# chkconfig --list nmb
230
+# chkconfig nmb on
231
+# chkconfig --list nmb
232
+# service nmb restart
233
+```
234
+
235
+### ファイアウォール設定
236
+ 1. 「システム/管理/ファイアーウォール」を起動。
237
+ 1. 「信頼したサービス」を選択。
238
+ 1. 「Samba」にチェックを入れる。
239
+ 1. 「OK」をクリック。
240
+ 1. 「適用」をクリック。
241
+
242
+### SELinux設定
243
+ 1. 「システム/管理/SELinux Management」を起動。
244
+ 1. rootパスワード入力。
245
+ 1. 「選択: ブーリアン値」を選択。
246
+ 1. 「Module: samba」の「Allow samba to share any file/directory read/write.」にチェックを入れる。
247
+ 1. SELinuxの変更を反映させるため、Fedoraを再起動。
248
+
249
+### リンク
250
+- [Windowsファイルサーバー構築(Samba)](http://fedorasrv.com/samba.shtml) @ [Fedoraで自宅サーバー構築](http://fedorasrv.com/)
251
+
252
+## BIND設定
253
+- 外部ドメインの名前解決できない場合の対策(検索結果のキャッシュに失敗している)
254
+ - SELinuxの「Allow BIND to write the master zone files. Generally this is used for dynamic DNS.(named_write_master_zones)」にチェックを入れる。
255
+- 「named: the working directory is not writable」対応
256
+```
257
+# chmod 770 /var/named/chroot/var/named
258
+```
259
+
260
+### リンク
261
+- [DNSサーバー構築(BIND)](http://fedorasrv.com/bind.shtml) @ [Fedoraで自宅サーバー構築](http://fedorasrv.com/)
262
+- [実用 BIND 9で作るDNSサーバ](http://www.atmarkit.co.jp/flinux/index/indexfiles/index-linux.html#bind9)
263
+
264
+## logwatch設定
265
+- インストールされているかどうか確認
266
+```
267
+# rpm -qa | grep logwatch
268
+```
269
+- インストール
270
+```
271
+# yum install logwatch
272
+```
273
+
274
+## mcelog エラーメッセージ対応
275
+- 次のレポートメールが間違って飛ぶのを抑制する。
276
+```
277
+/etc/cron.hourly/mcelog.cron:
278
+read: No such device
279
+```
280
+- mcelog をアンインストールする。
281
+```
282
+# yum erase mcelog
... ...
\ No newline at end of file
Linux/Install/Fedora7.md
... ...
@@ -0,0 +1,94 @@
1
+# Fedora 7
2
+[[_TOC_]]
3
+
4
+## yumの設定
5
+### 自動的に近いミラーを参照するようにする
6
+```
7
+yum -y install yum-fastestmirror
8
+```
9
+
10
+### パッケージのアップデートと自動更新の設定
11
+/etc/cron.daily/yum.cron
12
+```
13
+#!/bin/sh
14
+/usr/bin/yum -y update yum > /dev/null 2>&1 ; \
15
+/usr/bin/yum -y update > /dev/null 2>&1
16
+```
17
+
18
+/etc/cron.weekly/yum.cron
19
+```
20
+#!/bin/sh
21
+/usr/bin/yum -e 0 -d 0 clean packages
22
+```
23
+
24
+## VNCの設定
25
+VNC Serverのインストール
26
+```
27
+yum -y install vnc-server
28
+```
29
+
30
+/etc/services
31
+```
32
+vnc1024 5901/tcp # RealVNC 1024x768
33
+vnc1280 5902/tcp # RealVNC 1280x1024
34
+```
35
+
36
+/etc/xinetd.d/vnc1024
37
+```
38
+service vnc1024
39
+{
40
+ disable = no
41
+ port = 5901
42
+ socket_type = stream
43
+ wait = no
44
+# only_from = 192.168.0.0/24
45
+# no_access = xxx.xxx.xxx.xxx
46
+ user = nobody
47
+ server = /usr/bin/Xvnc
48
+ server_args = -inetd -broadcast -query 127.0.0.1 -once -geometry 1024x768 -dpi 96 -depth 16 -securitytypes=none
49
+ log_on_failure += USERID
50
+}
51
+```
52
+
53
+/etc/xinetd.d/vnc1280
54
+```
55
+service vnc1280
56
+{
57
+ disable = no
58
+ port = 5902
59
+ socket_type = stream
60
+ wait = no
61
+ only_from = 192.168.0.0/24
62
+# no_access = xxx.xxx.xxx.xxx
63
+ user = nobody
64
+ server = /usr/bin/Xvnc
65
+ server_args = -inetd -broadcast -query 127.0.0.1 -once -geometry 1280x1024 -dpi 96 -depth 16 -securitytypes=none
66
+ log_on_failure += USERID
67
+}
68
+```
69
+
70
+/etc/gdm/custom.conf
71
+```
72
+[daemon]
73
+KillInitClients=false
74
+GtkModulesList=
75
+AddGtkModules=false
76
+
77
+[xdmcp]
78
+Enable=true
79
+
80
+[greeter]
81
+IncludeAll=false
82
+```
83
+- [Fedora 12で xinetd, VNC, &#x58;DMCP (手順編)](http://blog.glatts.com/blog/imai/?p=639)
84
+
85
+## ファイアウォールの設定
86
+- /etc/sysconfig/iptables でrecentを使ってDoS攻撃を防ぐ。(下記はdnsの場合)
87
+```
88
+-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 53 -m recent --name DNS --set
89
+-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 53 -m recent --name DNS --update --rttl --seconds 60 --hitcount 5 -j DROP
90
+-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
91
+```
92
+- iptablesは上から評価されるので、防ぎたいポートの上にrecentを記述する。
93
+- [sshへの総当り攻撃をiptablesの2行で防ぐ方法](http://blog.browncat.org/2007/07/sshiptables2.html)
94
+- [iptables の ipt_recent で ssh の brute force attack 対策](http://www2s.biglobe.ne.jp/~nuts/labo/inti/ipt_recent.html)
... ...
\ No newline at end of file
Linux/Install/FedoraCore4.md
... ...
@@ -0,0 +1,97 @@
1
+# Fedora Core 4
2
+[[_TOC_]]
3
+
4
+## yumの設定
5
+### /etc/yum.repos.d/fedora.repo
6
+```
7
+[base]
8
+name=Fedora Core $releasever - $basearch - Base
9
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/$basearch/os/
10
+baseurl=http://ftp.jaist.ac.jp/pub/Linux/Fedora/core/$releasever/$basearch/os/
11
+ http://ftp.kddilabs.jp/Linux/packages/fedora/core/$releasever/$basearch/os/
12
+ http://ftp.riken.jp/Linux/fedora/core/$releasever/$basearch/os/
13
+ http://ftp.iij.ad.jp/pub/linux/fedora/core/$releasever/$basearch/os/
14
+#mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-$releasever
15
+enabled=1
16
+gpgcheck=1
17
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
18
+```
19
+
20
+### /etc/yum.repos.d/fedora-updates.repo
21
+```
22
+[updates-released]
23
+name=Fedora Core $releasever - $basearch - Released Updates
24
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/updates/$releasever/$basearch/
25
+baseurl=http://ftp.jaist.ac.jp/pub/Linux/Fedora/core/updates/$releasever/$basearch/
26
+ http://ftp.kddilabs.jp/Linux/packages/fedora/core/updates/$releasever/$basearch/
27
+ http://ftp.riken.jp/Linux/fedora/core/updates/$releasever/$basearch/
28
+ http://ftp.iij.ad.jp/pub/linux/fedora/core/updates/$releasever/$basearch/
29
+#mirrorlist=http://fedora.redhat.com/download/mirrors/updates-released-fc$releasever
30
+enabled=1
31
+gpgcheck=1
32
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora
33
+```
34
+
35
+### /etc/yum.repos.d/fedora-extras.repo
36
+```
37
+[extras]
38
+name=Fedora Extras $releasever - $basearch
39
+#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/extras/$releasever/$basearch/
40
+baseurl=http://ftp.jaist.ac.jp/pub/Linux/Fedora/extras/$releasever/$basearch/
41
+ http://ftp.kddilabs.jp/Linux/packages/fedora/extras/$releasever/$basearch/
42
+ http://ftp.riken.jp/Linux/fedora/extras/$releasever/$basearch/
43
+ http://ftp.iij.ad.jp/pub/linux/fedora/extras/$releasever/$basearch/
44
+#mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-extras-$releasever
45
+enabled=1
46
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-extras
47
+gpgcheck=1
48
+```
49
+
50
+### パッケージのアップデートと自動更新の設定
51
+```
52
+yum -y update
53
+/etc/init.d/yum start
54
+chkconfig yum on
55
+chkconfig --list yum
56
+yum -y remove up2date
57
+```
58
+
59
+## VNCの設定
60
+
61
+/etc/services
62
+```
63
+vnc 5901/tcp # RealVNC
64
+```
65
+
66
+/etc/xinetd.d/vnc
67
+```
68
+service vnc
69
+{
70
+ disable = no
71
+ port = 5901
72
+ socket_type = stream
73
+ wait = no
74
+ only_from = 192.168.0.0/24
75
+# no_access = xxx.xxx.xxx.xxx
76
+ user = nobody
77
+ server = /usr/bin/Xvnc
78
+ server_args = -inetd -broadcast -query 127.0.0.1 -once -geometry 1024x768 -dpi 96 -depth 16 -securitytypes=none
79
+ log_on_failure += USERID
80
+}
81
+```
82
+
83
+/etc/X11/gdm/gdm.conf
84
+```
85
+[daemon]
86
+KillInitClients=false
87
+[xdmcp]
88
+Enable=true
89
+```
90
+
91
+- [WindowsでLinuxをリモート操作(前編)](http://www.atmarkit.co.jp/flinux/special/vnc01/vnc01a.html)
92
+- [WindowsでLinuxをリモート操作(後編)](http://www.atmarkit.co.jp/flinux/special/vnc02/vnc02a.html)
93
+- 低速回線でも使用できる遠隔操作ソフト TightVNC [上](http://itpro.nikkeibp.co.jp/article/COLUMN/20061025/251809/) [中](http://itpro.nikkeibp.co.jp/article/COLUMN/20061025/251772/) [下](http://itpro.nikkeibp.co.jp/article/COLUMN/20061025/251813/)
94
+- [(Linux)vnc](http://t-doi.org/hiki/hiki.cgi?(Linux)vnc)
95
+- [RealVNC Ver.4.0 日本語版](http://blog.underdone.net/sb.cgi?cid=30)
96
+- [RealVNC](http://www.realvnc.com/)
97
+- [MacWiki:VNC](http://macwiki.sourceforge.jp/cgi-bin/wiki.cgi?%56%4e%43)
... ...
\ No newline at end of file
Linux/Link.md
... ...
@@ -0,0 +1,111 @@
1
+# Link
2
+
3
+- http://fedoraproject.org/ / [Download](https://fedoraproject.org/ja/get-fedora-options#formats)
4
+ - https://fedoraproject.org/wiki/ / [Releases](http://fedoraproject.org/wiki/Releases) / [Media Art](http://fedoraproject.org/wiki/Artwork/MediaArt) / [Flash](http://fedoraproject.org/wiki/Flash)
5
+ - http://torrent.fedoraproject.org/
6
+ - [Fedora Unity torrent](http://torrent.fedoraunity.org/)
7
+ - [Fedora JP Project](http://fedora.jp/)
8
+ - [Fedora Core@Ring Server](http://www.t.ring.gr.jp/archives/linux/fedora/linux/core/)
9
+
10
+- [www.centos.org](https://www.centos.org/)
11
+ - [Download](http://wiki.centos.org/Download)
12
+<!----- [[South American, Asian, Oceania, Middle Eastern, African and Other Regional Mirrors:http://www.centos.org/modules/tinycontent/index.php?id=32]]-->
13
+
14
+- [Red Hat Customer Portal](https://access.redhat.com/knowledge/docs/Red_Hat_Enterprise_Linux/)
15
+ - [仮想化管理ガイド](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html)
16
+ - [仮想化スタートガイド](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Getting_Started_Guide/index.html)
17
+ - [仮想化セキュリティガイド](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Security_Guide/index.html)
18
+
19
+- [Let's Encrypt](https://letsencrypt.org/) Free SSL/TLS Certificates
20
+ - [Let’s EncryptでSSLサーバー証明書を取得してみた – 稲葉サーバーデザイン](https://inaba-serverdesign.jp/blog/20151217/lets-encrypt.html)
21
+ - [Let’s Encrypt サーバー証明書の取得と自動更新設定メモ - あぱーブログ](https://blog.apar.jp/linux/3619/)
22
+
23
+- [The Apache HTTP Server Project](http://httpd.apache.org/) ([docs/2.0](http://httpd.apache.org/docs/2.0/))
24
+- [JAPACHE HTTP Server Project](http://japache.infoscience.co.jp/)
25
+- [日本Sambaユーザ会](http://www.samba.gr.jp/)
26
+- [日本MySQLユーザ会](http://www.mysql.gr.jp/)
27
+- [日本SELinuxユーザー会](http://www.selinux.gr.jp/)
28
+
29
+- [Tera Term Open Source Project](http://ttssh2.sourceforge.jp/)
30
+ - [ダウンロード](http://sourceforge.jp/projects/ttssh2/releases/)
31
+ - [ヘルプ 目次](http://ttssh2.sourceforge.jp/manual/ja/)
32
+ - [MACRO Help Index](http://ttssh2.sourceforge.jp/manual/ja/macro/)
33
+ - [Tera Termマクロ活用入門(1):各種ログインを自動化する - SourceForge.JP Magazine](http://sourceforge.jp/magazine/10/01/08/0825239)
34
+
35
+- [Fedoraで自宅サーバー構築](http://fedorasrv.com/)
36
+ - [CentOSで自宅サーバー構築](http://centossrv.com/)
37
+
38
+- [OSSでLinuxサーバ構築](http://www.oss-d.net/)
39
+ - [CentOS6.2/KVMによるサーバ仮想化](http://www.oss-d.net/virt/kvm/0.9)
40
+
41
+- [Fedora Core 5 Linux インストールノート](http://www.hyde-tech.com/HideWeb/fedora_core_5_installation_notes.html)
42
+
43
+- [Linux@2ch](http://pc11.2ch.net/linux/subback.html)
44
+- [自宅サーバ@2ch](http://pc11.2ch.net/mysv/subback.html)
45
+- [ネットワークセキュリティ@2ch](http://pc11.2ch.net/sec/subback.html)
46
+- [wiki@nothing:NTP](http://wiki.nothing.sh/page/%4e%54%50)
47
+- [InterNIC Whois Search](http://www.internic.net/whois.html)
48
+- [whois.jp](http://whois.jp/)
49
+- [MoeNIC](http://moenic.wyrm.jp/)
50
+- [sshへの総当り攻撃をiptablesの2行で防ぐ方法](http://blog.browncat.org/2007/07/sshiptables2.html)
51
+- [Outbound Port 25 Blocking](http://ja.wikipedia.org/wiki/%4f%75%74%62%6f%75%6e%64%5f%50%6f%72%74%5f%32%35%5f%42%6c%6f%63%6b%69%6e%67) (OP25B)
52
+- [迷惑メール対策委員会](http://salt.iajapan.org/wpmu/anti_spam/)
53
+ - [SPF(Sender Policy Framework)](http://salt.iajapan.org/wpmu/anti_spam/admin/tech/explanation/spf/)
54
+- [Sendmail](http://www.sendmail.co.jp/) / [SPFレコードチェック](http://www.sendmail.co.jp/sa/spfcheck.html)
55
+- [OpenVPN on Mac OS X Leopard](http://bam-system.ddo.jp:8080/ura/50)
56
+- [さくらインターネット オンラインマニュアル](http://support.sakura.ad.jp/manual/)
57
+ - [さくらのクラウド / 基本的な設定](http://support.sakura.ad.jp/manual/cloud/basic/)
58
+ - [さくらのVPS / OSセットアップ情報](http://support.sakura.ad.jp/manual/vps/ossetup.html)
59
+
60
+- Postfix Mail送信
61
+- Dovecot Mail受信
62
+- Postgrey spam対策ツール
63
+- Mailman Mailing List管理
64
+
65
+- [Apache JMeter](http://jakarta.apache.org/jmeter/)
66
+ - [JMeterによるWebサーバ性能評価の勘所](http://www.atmarkit.co.jp/flinux/rensai/apache2_02/apache02a.html)
67
+ - [JMeter解説](http://www.techscore.com/tech/ApacheJakarta/JMeter/)
68
+ - [JMeter(高機能/フリーなテストツール)](http://www.stackasterisk.jp/tech/engineer/jmeter01_01.jsp)
69
+- [OpenSTA](http://www.opensta.org/)
70
+ - [負荷テストの基本を学ぶ](http://www.itarchitect.jp/methodology_and_design/-/28761.html)
71
+- [WebLOAD](http://www.webload.org/)
72
+ - [WebLOAD: 商用の負荷テストツールが最近オープンソース化された](http://www.infoq.com/jp/news/2007/09/webload)
73
+- [Selenium](http://seleniumhq.org/) ([日本語](http://oss.infoscience.co.jp/seleniumhq/))
74
+ - JavaScript/Selenium
75
+ - [日本語ドキュメント](http://oss.infoscience.co.jp/seleniumhq/docs/)
76
+ - [ブラウザを選ばずWebテストを自動化するSelenium](http://www.atmarkit.co.jp/fjava/rensai4/devtool07/devtool07_1.html)
77
+ - [Selenium IDEで1つ1つのテストの処理時間を計測 (悪戦苦闘) - bonlife](http://d.hatena.ne.jp/bonlife/20080213/1202913177)
78
+ - [SeleniumでJavaScriptを使う方法いろいろ(変数・関数などの利用)](http://colo-ri.jp/develop/2008/04/seleniumjavascript.html)
79
+ - [Selenium IDE で無限ループ - ヽ( ・∀・)ノくまくまー - s21g](http://blog.s21g.com/articles/1619)
80
+ - [[Selenium による Web アプリの自動テスト>JavaScript#Selenium]]
81
+
82
+- [IP List for PeerGuardian 2](http://iplist.wave.prohosting.com/)
83
+
84
+- [@IT:Adobe Reader 7.0を使うには](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/720acrobat7.html)
85
+ - [Asian and Central European font packs for Adobe Reader](http://www.adobe.com/products/acrobat/acrrasianfontpack.html)
86
+
87
+- [@IT:Linux Square全記事インデックス](http://www.atmarkit.co.jp/flinux/index/indexfiles/index-linux.html)
88
+ - [実用 BIND 9で作るDNSサーバ](http://www.atmarkit.co.jp/flinux/index/indexfiles/index-linux.html#bind9)
89
+
90
+- [@IT:Linux Tips Index](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/tipsindex.html)
91
+ - [コンソール/ターミナル](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/tipsindex_cons.html)
92
+ - [ログアウトしてもプログラムを実行し続けるには](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/352nostopprog.html) nohup
93
+
94
+- [自分Linuxを作り出せ](http://itpro.nikkeibp.co.jp/members/bn/mokuji.jsp?OFFSET=0&MAXCNT=20&TOP_ID=241034)
95
+- [誰が攻撃しているか突き止めたい](http://itpro.nikkeibp.co.jp/article/COLUMN/20061212/256736/)
96
+- [Linuxトラブル対策大全](http://itpro.nikkeibp.co.jp/members/bn/mokuji.jsp?OFFSET=0&MAXCNT=30&TOP_ID=251195&ST=lin-os)
97
+- [Linuxコマンド集 INDEX](http://itpro.nikkeibp.co.jp/article/COLUMN/20060224/230573/)
98
+- [ホワイトハッカー道場](http://itpro.nikkeibp.co.jp/article/COLUMN/20070927/283156/)
99
+- [シェル・スクリプト・リファレンス INDEX](http://itpro.nikkeibp.co.jp/article/COLUMN/20060224/230580/)
100
+- [プロが愛用するネット管理のフリー・ツール](http://itpro.nikkeibp.co.jp/article/COLUMN/20071002/283498/)
101
+- [セキュリティ強化に今すぐ役立つ便利サイト特集](http://itpro.nikkeibp.co.jp/article/COLUMN/20070703/276512/)
102
+- [管理者のためのコマンド活用講座](http://itpro.nikkeibp.co.jp/article/COLUMN/20100224/345030/)
103
+- [Tracで開発現場を交通整理](http://itpro.nikkeibp.co.jp/article/COLUMN/20080417/299373/)
104
+- [触ってみよう!ビッグデータを支えるクラウド技術:ITpro](http://itpro.nikkeibp.co.jp/article/COLUMN/20120306/384801/)<br />
105
+Hadoop/memcached/kumofs/ROMA/NoSQL/MongoDB/Cassandra
106
+- [フリーツールでネットトラブル解決 - フリーツールでネットトラブル解決:ITpro](http://itpro.nikkeibp.co.jp/article/COLUMN/20120327/388077/)<br />
107
+Wireshark/tcpdump
108
+- [【仮想化道場】 Linux標準のサーバー仮想化機能「KVM」を試す -クラウド Watch](http://cloud.watch.impress.co.jp/docs/column/virtual/20110606_450502.html)
109
+- [CMAN インターネットサービス](https://www.cman.jp/)
110
+ - [サーバー監視](https://www.cman.jp/network/)
111
+ - [アクセス情報【使用中のIPアドレス確認】](https://www.cman.jp/network/support/go_access.cgi)
Linux/NIC_Bonding.md
... ...
@@ -0,0 +1,134 @@
1
+[[_TOC_]]
2
+
3
+# NICの冗長化
4
+- Linux ではネットワークアダプタのチーミングを「bonding」と呼ぶ。
5
+
6
+- NetworkManager は設定を勝手に変更する(?)ようなので network を使うようにする。
7
+```
8
+# chkconfig --list | grep -i network
9
+NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
10
+network 0:off 1:off 2:off 3:off 4:off 5:off 6:off
11
+# chkconfig NetworkManager off
12
+# chkconfig network on
13
+# chkconfig --list | grep -i network
14
+NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
15
+network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
16
+# service NetworkManager stop
17
+# service network restart
18
+```
19
+
20
+# 設定例
21
+| 仮想NIC名 | bond0 |
22
+| --- | --- |
23
+| 動作モード | 6 … Active Load Balancing (ALB, 負荷分散+耐障害性, 受信アダプタ固定) |
24
+| IPアドレス設定 | 固定IP |
25
+| IPアドレス | 192.168.0.2 |
26
+| MASTER | bond0 |
27
+| SLAVE | eth0, eth1 |
28
+
29
+- /etc/modprobe.d/bonding.conf
30
+```
31
+alias bond0 bonding
32
+options bond0 mode=6
33
+```
34
+
35
+- /etc/sysconfig/network-scripts/ifcfg-bond0
36
+```
37
+# Virtual NIC bond0 setting
38
+DEVICE=bond0
39
+BOOTPROTO=static
40
+IPADDR=192.168.0.2
41
+NETMASK=255.255.255.0
42
+NETWORK=192.168.0.0
43
+BROADCAST=192.168.0.255
44
+GATEWAY=192.168.0.1
45
+DNS1=192.168.0.2
46
+IPV6ADDR=
47
+IPV6PREFIX=
48
+ONBOOT=yes
49
+#USERCTL=no
50
+TYPE=Ethernet
51
+DEFROUTE=yes
52
+IPV4_FAILURE_FATAL=yes
53
+IPV6INIT=no
54
+#NAME="System bond0"
55
+```
56
+
57
+- /etc/sysconfig/network-scripts/ifcfg-eth0 (eth1も同様に。)<br />
58
+MACアドレス(HWADDR)はそれぞれのNICの値を設定する。
59
+```
60
+# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
61
+DEVICE=eth0
62
+HWADDR=XX:XX:XX:XX:XX:XX
63
+BOOTPROTO=none
64
+ONBOOT=yes
65
+MASTER=bond0
66
+SLAVE=yes
67
+TYPE=Ethernet
68
+```
69
+
70
+- 動作確認
71
+```
72
+# service network restart
73
+# ifconfig
74
+bond0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
75
+ inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0
76
+ inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
77
+ UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
78
+ RX packets:XXXX errors:0 dropped:0 overruns:0 frame:0
79
+ TX packets:XXXX errors:0 dropped:0 overruns:0 carrier:0
80
+ collisions:0 txqueuelen:0
81
+ RX bytes:XXXX (XXXX MiB) TX bytes:XXXX (XXXX MiB)
82
+
83
+eth0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
84
+ UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
85
+ RX packets:XXXX errors:0 dropped:0 overruns:0 frame:0
86
+ TX packets:XXXX errors:0 dropped:0 overruns:0 carrier:0
87
+ collisions:0 txqueuelen:1000
88
+ RX bytes:XXXX (XXXX MiB) TX bytes:XXXX (XXXX MiB)
89
+ Interrupt:XX Base address:0xXXXX
90
+
91
+eth1 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX
92
+ UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
93
+ RX packets:XXXX errors:0 dropped:0 overruns:0 frame:0
94
+ TX packets:XXXX errors:0 dropped:0 overruns:0 carrier:0
95
+ collisions:0 txqueuelen:1000
96
+ RX bytes:XXXX (XXXX MiB) TX bytes:XXXX (XXXX MiB)
97
+ Interrupt:XX Base address:0xXXXX
98
+
99
+lo Link encap:Local Loopback
100
+ inet addr:127.0.0.1 Mask:255.0.0.0
101
+ inet6 addr: ::1/128 Scope:Host
102
+ UP LOOPBACK RUNNING MTU:16436 Metric:1
103
+ RX packets:XXXX errors:0 dropped:0 overruns:0 frame:0
104
+ TX packets:XXXX errors:0 dropped:0 overruns:0 carrier:0
105
+ collisions:0 txqueuelen:0
106
+ RX bytes:XXXX (XXXX MiB) TX bytes:XXXX (XXXX MiB)
107
+```
108
+
109
+- 動作確認その2。使用するNICを指定して[arping](http://ja.wikipedia.org/wiki/%41%72%70%69%6e%67)。
110
+```
111
+# arping -c 5 -I bond0 192.168.0.x
112
+# arping -c 5 -I eth0 192.168.0.x
113
+# arping -c 5 -I eth1 192.168.0.x
114
+```
115
+
116
+# エラー対応
117
+
118
+## ARPキャッシュポイズニング攻撃
119
+- 同一IPアドレスを複数のMACアドレスに割り当てることになるため、サーバからのアクセスをクライアントがARPキャッシュポイズニング攻撃と誤判定することがある。
120
+- サーバからのアクセスに対しクライアント側のファイアウォールに例外を許可するよう設定する。
121
+
122
+# リンク
123
+- [bondingの設定](http://spacesheriffsharivan.blog9.fc2.com/blog-entry-83.html)
124
+
125
+- [[Fedora]サーバ初期設定メモ](http://www.massi.mydns.jp/massis_easy_laboratory/2010/04/fedora-1.html)
126
+
127
+- [[network] CentOSにおけるbonding設定メモ](http://nullpopopo.blogcube.info/2009/01/network-centosbonding.html)
128
+
129
+- [[CentOS] ボンディングを構成する](http://kaede.blog.abk.nu/rh-bonding)
130
+
131
+- [41.5.2.1. bonding Module Directives](http://www.centos.org/docs/5/html/5.2/Deployment_Guide/s3-modules-bonding-directives.html)
132
+
133
+- [Arping](http://ja.wikipedia.org/wiki/%41%72%70%69%6e%67)
134
+ - [GitHub:ThomasHabets/arping](https://github.com/ThomasHabets/arping)
... ...
\ No newline at end of file
Linux/OpenVPN.md
... ...
@@ -0,0 +1,252 @@
1
+[[_TOC_]]
2
+
3
+# ネットワーク構成
4
+- サーバ側ネットワーク(192.168.1.0)
5
+| ルータ | 192.168.1.1 |
6
+| --- | --- |
7
+| VPNサーバ | 192.168.1.2 |
8
+| アプリケーションサーバ1 | 192.168.1.3 |
9
+| アプリケーションサーバ2 | 192.168.1.4 |
10
+- サーバ/クライアント間用仮想ネットワーク(10.8.0.0)
11
+- クライアント側ネットワーク(192.168.0.0)
12
+
13
+- サーバ側ネットワークとクライアント側ネットワークは異なるゾーンである必要がある。
14
+
15
+## スタティックルーティング
16
+- VPNサーバ単体とだけ接続できれば良い場合は、設定の必要なし。
17
+- ルータ下の複数のPCに接続する場合は、ルータにスタティックルーティングを設定する必要あり。
18
+- クライアントからアプリケーションサーバにアクセスしているとき、アプリケーションサーバでは 10.8.0.x からアクセスされているように見える。戻りパケットを 10.8.0.x に投げるので、10.8.0.0 用のゲートウェイ設定が無いとクライアントに応答が返ってこない。
19
+- 10.8.0.0 宛てのパケットのゲートウェイとして VPN サーバのローカルアドレスを設定する。
20
+ - any net 10.8.0.0 netmask 255.255.255.0 gw 192.168.1.2
21
+
22
+## ファイアウォール
23
+- UDP:1194 を開放し、192.168.1.2 にポート転送する。
24
+```
25
+# firewall-cmd --permanent --add-service=openvpn
26
+# firewall-cmd --reload
27
+```
28
+
29
+## 仮想NIC
30
+- VPNサーバにネットワークI/Fが1つだけしか無く、グローバルIP用として使われていて、ローカルネットが存在しない場合は、VPNサーバに仮想NICを追加する。
31
+- /etc/sysconfig/network-scripts/ifcfg-eth0:0
32
+```
33
+DEVICE="eth0:0"
34
+IPADDR=192.168.1.2
35
+PREFIX=24
36
+ONBOOT=yes
37
+BOOTPROTO=none
38
+```
39
+
40
+# インストール
41
+```
42
+# yum install openvpn (epelリポジトリ)
43
+# cd /etc/openvpn/
44
+# curl -LO https://github.com/OpenVPN/easy-rsa/archive/master.zip
45
+# unzip master.zip
46
+# mv easy-rsa-master/easyrsa3/ .
47
+# rm -rf easy-rsa-master/
48
+# rm -f master.zip
49
+```
50
+
51
+# サーバ設定
52
+## CA証明書・秘密鍵作成
53
+```
54
+# cd /etc/openvpn/easyrsa3/
55
+# ./easyrsa init-pki (OpenVPNインストール後初回のみ実行する)
56
+# ./easyrsa build-ca (PEM pass phrase, Common Name を入力)
57
+# cp pki/ca.crt /etc/openvpn/
58
+```
59
+
60
+## サーバー証明書・秘密鍵作成
61
+```
62
+# ./easyrsa build-server-full server nopass (CAのパスフレーズを入力)
63
+# cp pki/issued/server.crt /etc/openvpn/
64
+# cp pki/private/server.key /etc/openvpn/
65
+```
66
+
67
+## Diffie Hellman パラメータ作成
68
+```
69
+# ./easyrsa gen-dh
70
+# cp pki/dh.pem /etc/openvpn/
71
+```
72
+
73
+## 証明書廃止リスト作成
74
+- /etc/openvpn/easyrsa3/vars (vars.example をコピー)
75
+```
76
+#set_var EASYRSA_CRL_DAYS 180
77
+set_var EASYRSA_CRL_DAYS 3650
78
+```
79
+
80
+```
81
+# ./easyrsa build-client-full dmy nopass (CAのパスフレーズを入力)
82
+# ./easyrsa revoke dmy (yes応答, CAのパスフレーズを入力)
83
+# ./easyrsa gen-crl (CAのパスフレーズを入力)
84
+# cp /etc/openvpn/easyrsa3/pki/crl.pem /etc/openvpn/
85
+# chmod o+r /etc/openvpn/crl.pem
86
+```
87
+
88
+## OpenVPN設定
89
+```
90
+# openvpn --genkey --secret /etc/openvpn/ta.key
91
+# cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn/
92
+```
93
+
94
+- /etc/openvpn/server.conf
95
+```
96
+port 1194
97
+
98
+proto udp
99
+
100
+dev tun
101
+
102
+;dh dh2048.pem
103
+dh dh.pem
104
+
105
+server 10.8.0.0 255.255.255.0
106
+
107
+push "route 192.168.1.0 255.255.255.0"
108
+
109
+;tls-auth ta.key 0
110
+tls-auth ta.key 0
111
+
112
+;cipher BF-CBC # Blowfish (default)
113
+cipher AES-256-CBC
114
+
115
+;user nobody
116
+;group nobody
117
+user nobody
118
+group nobody
119
+
120
+;status openvpn-status.log
121
+status /var/log/openvpn-status.log
122
+
123
+;log-append openvpn.log
124
+log-append /var/log/openvpn.log
125
+
126
+crl-verify crl.pem
127
+```
128
+
129
+- /etc/openvpn/openvpn-startup
130
+```bash
131
+#!/bin/bash
132
+
133
+# VPNインタフェースiptablesルール削除スクリプト実行※必須
134
+/etc/openvpn/openvpn-shutdown
135
+
136
+# VPNサーバーからの送信を許可※必須
137
+iptables -I OUTPUT -o tun+ -j ACCEPT
138
+iptables -I FORWARD -o tun+ -j ACCEPT
139
+
140
+# VPNクライアントからVPNサーバーへのアクセスを許可する場合
141
+iptables -I INPUT -i tun+ -j ACCEPT
142
+
143
+# VPNクライアントからLANへのアクセスを許可する場合
144
+# (例としてVPNクライアントから192.168.1.0/24へのアクセスを許可する場合)
145
+# ※192.168.1.0/24側のファイアウォール等でVPNクライアント(10.8.0.0/24)からのアクセスを許可すること
146
+iptables -I FORWARD -i tun+ -d 192.168.1.0/24 -j ACCEPT
147
+```
148
+
149
+- /etc/openvpn/openvpn-shutdown
150
+```bash
151
+#!/bin/bash
152
+
153
+# VPNインタフェース(tun+)用iptablesルール削除関数
154
+delete() {
155
+ rule_number=`iptables -L $target --line-numbers -n -v|grep tun.|awk '{print $1}'|sort -r`
156
+ for num in $rule_number
157
+ do
158
+ iptables -D $target $num
159
+ done
160
+}
161
+
162
+# VPNインタフェース(tun+)用iptables受信ルール削除
163
+target='INPUT'
164
+delete
165
+
166
+# VPNインタフェース(tun+)用iptables転送ルール削除
167
+target='FORWARD'
168
+delete
169
+
170
+# VPNインタフェース(tun+)用iptables送信ルール削除
171
+target='OUTPUT'
172
+delete
173
+```
174
+
175
+- /etc/logrotate.d/openvpn
176
+```
177
+/var/log/openvpn.log {
178
+ missingok
179
+ notifempty
180
+ sharedscripts
181
+ postrotate
182
+ systemctl restart openvpn 2>&1 > /dev/null || true
183
+ endscript
184
+}
185
+```
186
+
187
+- /etc/rc.d/init.d/openvpn (コメントを解除)
188
+```
189
+ #echo 1 > /proc/sys/net/ipv4/ip_forward
190
+ echo 1 > /proc/sys/net/ipv4/ip_forward
191
+```
192
+
193
+## サービス起動
194
+- CentOS 7
195
+```
196
+# systemctl start openvpn@server
197
+# systemctl enable openvpn@server
198
+```
199
+
200
+# クライアント用設定
201
+
202
+## クライアント証明書・秘密鍵作成
203
+```
204
+# cd /etc/openvpn/easyrsa3/
205
+# ./easyrsa build-client-full client1 (client1用のパスフレーズ, CAのパスフレーズを入力)
206
+```
207
+
208
+## クライアント設定ファイル
209
+- ファイルをクライアントマシンに転送。
210
+ - /etc/openvpn/ca.crt
211
+ - /etc/openvpn/ta.key
212
+ - /etc/openvpn/easyrsa3/pki/issued/client1.crt
213
+ - /etc/openvpn/easyrsa3/pki/private/client1.key
214
+ - /usr/share/doc/openvpn-*/sample/sample-config-files/client.conf
215
+
216
+- C:/Program Files/OpenVPN/config 以下に上記ファイルを配置。
217
+
218
+## クライアント設定
219
+- client.conf を client.ovpn にリネーム。
220
+- %HomePath%/OpenVPN/config/client.ovpn
221
+```
222
+# OpenVPN サーバ名とポート
223
+remote vpn.takeash.net 1194
224
+
225
+ca ca.crt
226
+cert client1.crt
227
+key client1.key
228
+
229
+remote-cert-tls server
230
+
231
+;tls-auth ta.key 1
232
+tls-auth ta.key 1
233
+
234
+;cipher x
235
+cipher AES-256-CBC
236
+```
237
+
238
+## 複数拠点に同時接続
239
+- 同時接続する拠点分の TAP Windows Adapter が必要。
240
+- Adapter を追加するには、「プログラム / TAP-Windows / Utilities / Add a new TAP virtual ethernet adapter」を右クリックし「管理者として実行」を選択する。
241
+```
242
+"C:\Program Files\TAP-Windows\bin\tapinstall.exe" install "C:\Program Files\TAP-Windows\driver\OemVista.inf" tap0901
243
+```
244
+
245
+- [How to connect multiple VPNs using OpenVPN on Windows 7 on the same time? - Server Fault](http://serverfault.com/questions/155299/)
246
+
247
+# リンク
248
+- [CentOSで自宅サーバー構築](http://centossrv.com/)
249
+ - [VPNサーバー構築(OpenVPN)](http://centossrv.com/openvpn.shtml)
250
+
251
+- [OpenVPN](https://openvpn.net/)
252
+ - [Downloads](https://openvpn.net/index.php/open-source/downloads.html)
... ...
\ No newline at end of file
Linux/Redmine.md
... ...
@@ -0,0 +1,300 @@
1
+[[_TOC_]]
2
+
3
+# リンク
4
+- http://www.redmine.org/
5
+ - [日本語ガイド](http://www.redmine.org/projects/redmine/wiki/JaGuide)
6
+ - [GitHub:redmine/redmine](https://github.com/redmine/redmine)
7
+
8
+- http://redmine.jp/
9
+ - [Redmine 3.2をCentOS 7.1にインストールする手順 - Redmine.JP Blog](http://blog.redmine.jp/articles/3_2/install/centos/)
10
+ - [Redmine 3.1をCentOS 7.1にインストールする手順 - Redmine.JP Blog](http://blog.redmine.jp/articles/3_1/installation_centos/)
11
+
12
+- [Ruby on Railsで作られたプロジェクト管理ツールredMineを使ってみよう! … 技術評論社](http://gihyo.jp/dev/serial/01/redmine)
13
+
14
+- [RedmineがExcelよりも素晴らしい点: プログラマの思索](http://forza.cocolog-nifty.com/blog/2008/05/redmineexcel_7014.html)
15
+
16
+- [Redmine運用メモ](http://www.02.246.ne.jp/~torutk/swetools/redmine/operation.html)
17
+
18
+- [Redmineでのタスクの進捗報告について - いぬおせろ](http://d.hatena.ne.jp/wankomagic/20111218/1324204190)
19
+
20
+# インストール
21
+## 環境
22
+| ソフトウェア | バージョン |
23
+| --- | --- |
24
+| Redmine | Redmine 3.3.2 |
25
+| OS | CentOS 7.3 |
26
+| データベース | MariaDB 5.5.52 |
27
+| webサーバ | Apache 2.4.6 |
28
+| Ruby | Ruby 2.0.0 |
29
+| Passenger | Passenger 5.1.2 |
30
+| バージョン管理システム | Git 1.8.3.1 |
31
+
32
+## パッケージのインストール
33
+- 開発環境
34
+```
35
+# yum -y groupinstall "Development Tools"
36
+# yum -y install openssl-devel readline-devel zlib-devel curl-devel libyaml-devel libffi-devel
37
+```
38
+
39
+- Ruby (CentOS-Base リポジトリ)
40
+```
41
+# yum -y install ruby ruby-devel
42
+```
43
+
44
+- MariaDB
45
+```
46
+# yum -y install mariadb-server mariadb-devel
47
+```
48
+
49
+- Apache
50
+```
51
+# yum -y install httpd httpd-devel
52
+```
53
+
54
+- ImageMagickとヘッダファイル・日本語フォント
55
+```
56
+# yum -y install ImageMagick ImageMagick-devel ipa-pgothic-fonts
57
+```
58
+
59
+- bundler
60
+```
61
+# gem install bundler --no-rdoc --no-ri
62
+```
63
+
64
+## MariaDB
65
+- /etc/my.cnf (抜粋)
66
+```
67
+[mysqld]
68
+character-set-server=utf8
69
+
70
+[mysql]
71
+default-character-set=utf8
72
+```
73
+- 起動 & サービス登録
74
+```
75
+# systemctl start mariadb
76
+# systemctl enable mariadb
77
+```
78
+- 設定確認
79
+```
80
+# mysql -u root
81
+> show variables like 'character_set%'; (filesystem と dir 以外全てが utf8 になっていること)
82
++--------------------------+----------------------------+
83
+| Variable_name | Value |
84
++--------------------------+----------------------------+
85
+| character_set_client | utf8 |
86
+| character_set_connection | utf8 |
87
+| character_set_database | utf8 |
88
+| character_set_filesystem | binary |
89
+| character_set_results | utf8 |
90
+| character_set_server | utf8 |
91
+| character_set_system | utf8 |
92
+| character_sets_dir | /usr/share/mysql/charsets/ |
93
++--------------------------+----------------------------+
94
+> exit
95
+```
96
+- 初期設定
97
+```
98
+# mysql_secure_installation
99
+...
100
+Enter current password for root (enter for none): (そのままエンター)
101
+...
102
+Set root password? [Y/n] (y応答)
103
+New password: (新 root パスワードを入力)
104
+Re-enter new password: (パスワード再入力)
105
+...
106
+Remove anonymous users? [Y/n] (y応答)
107
+...
108
+Disallow root login remotely? [Y/n] (y応答)
109
+...
110
+Remove test database and access to it? [Y/n] (y応答)
111
+...
112
+Reload privilege tables now? [Y/n] (y応答)
113
+```
114
+- Redmine用データベースとユーザーの作成
115
+```
116
+# mysql -u root -p
117
+> create database db_redmine default character set utf8;
118
+> grant all on db_redmine.* to user_redmine@localhost identified by '********';
119
+(******** は user_redmine 用のパスワードを記述する)
120
+> flush privileges;
121
+> exit;
122
+```
123
+
124
+## Redmine のインストール
125
+- [GitHub:redmine/redmine](https://github.com/redmine/redmine)
126
+```
127
+# curl -L -o redmine_3.3.2.zip https://github.com/redmine/redmine/archive/master.zip
128
+# unzip redmine_3.3.2.zip
129
+# mv redmine-master/ /var/lib/redmine
130
+```
131
+- /var/lib/redmine/config/database.yml
132
+```
133
+production:
134
+ adapter: mysql2
135
+ database: db_redmine
136
+ host: localhost
137
+ username: user_redmine
138
+ password: "********"
139
+ encoding: utf8
140
+```
141
+- /var/lib/redmine/config/configuration.yml
142
+```
143
+production:
144
+ email_delivery:
145
+ delivery_method: :smtp
146
+ smtp_settings:
147
+ address: "localhost"
148
+ port: 25
149
+ domain: "example.com"
150
+
151
+ rmagick_font_path: /usr/share/fonts/ipa-pgothic/ipagp.ttf
152
+```
153
+
154
+## gemパッケージのインストール
155
+```
156
+# cd /var/lib/redmine
157
+# bundle install --without development test --path vendor/bundle
158
+```
159
+
160
+## Passenger のインストール (mod_passenger)
161
+- [Installing Passenger + Apache on Red Hat 7 / CentOS 7 (with RPM) - Passenger Library](https://www.phusionpassenger.com/library/install/apache/install/oss/el7/)
162
+```
163
+# yum install pygpgme curl
164
+# curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
165
+# yum install -y mod_passenger || yum-config-manager --enable cr && yum install -y mod_passenger
166
+# /usr/bin/passenger-config validate-install (設定確認)
167
+# systemctl restart httpd
168
+# /usr/sbin/passenger-memory-stats
169
+```
170
+
171
+- /etc/httpd/conf.d/passenger.conf
172
+```
173
+### Begin automatically installed Phusion Passenger config snippet ###
174
+<IfModule mod_passenger.c>
175
+ PassengerRoot /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini
176
+ PassengerRuby /usr/bin/ruby
177
+ PassengerInstanceRegistryDir /var/run/passenger-instreg
178
+</IfModule>
179
+### End automatically installed Phusion Passenger config snippet ###
180
+
181
+# Deploying a web application: an example
182
+
183
+# Suppose you have a web application in /somewhere. Add a virtual host to
184
+# your Apache configuration file and set its DocumentRoot to /somewhere/public:
185
+
186
+<VirtualHost *:80>
187
+ ServerName redmine.example.com
188
+ # !!! Be sure to point DocumentRoot to 'public'!
189
+ DocumentRoot /var/lib/redmine/public
190
+ <Directory /var/lib/redmine/public>
191
+ # This relaxes Apache security settings.
192
+ AllowOverride all
193
+ # MultiViews must be turned off.
194
+ Options -MultiViews
195
+ # 画像ファイル・CSSファイル等へのアクセスを許可する
196
+ Require all granted
197
+ </Directory>
198
+</VirtualHost>
199
+
200
+# Passengerが追加するHTTPヘッダを削除するための設定(任意)。
201
+Header always unset "X-Powered-By"
202
+Header always unset "X-Runtime"
203
+
204
+# 必要に応じてPassengerのチューニングのための設定を追加(任意)。
205
+# 詳しくはPhusion Passenger users guide(https://www.phusionpassenger.com/library/config/apache/reference/)参照。
206
+PassengerMaxPoolSize 20
207
+PassengerMaxInstancesPerApp 4
208
+PassengerPoolIdleTime 864000
209
+PassengerHighPerformance on
210
+PassengerStatThrottleRate 10
211
+PassengerSpawnMethod smart
212
+PassengerFriendlyErrorPages off
213
+```
214
+
215
+- [Deploying a Ruby application - Apache - Passenger Library](https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/)
216
+
217
+# 初期設定
218
+```
219
+# bundle exec rake generate_secret_token
220
+# RAILS_ENV=production bundle exec rake db:migrate
221
+# RAILS_ENV=production REDMINE_LANG=ja bundle exec rake redmine:load_default_data
222
+```
223
+
224
+# SELinux
225
+- [Fedora Manpages: passenger_selinux(8)](http://linuxmanpages.net/manpages/fedora21/man8/passenger_selinux.8.html)
226
+- &#x7e;/SetSecurityFlags.sh
227
+```
228
+#!/bin/bash
229
+
230
+chown -R apache. /var/lib/redmine
231
+chcon -Rh -t httpd_sys_content_t /var/lib/redmine
232
+cd /var/lib/redmine
233
+chcon -Rh -t httpd_log_t log
234
+chcon -Rh -t httpd_tmpfs_t tmp
235
+chcon -Rh -t httpd_sys_rw_content_t files public/plugin_assets
236
+find . -name '*.so' | xargs -i chcon -Rvh -t httpd_modules_t {}
237
+
238
+# リポジトリとして使用するフォルダ
239
+chcon -Rh -t public_content_t /home/Shared/
240
+```
241
+
242
+# 起動 & サービス登録
243
+```
244
+# firewall-cmd --add-service=http --permanent
245
+# firewall-cmd --reload
246
+# systemctl start httpd
247
+# systemctl enable httpd
248
+```
249
+
250
+# カスタマイズ
251
+- [Redmineを使い始めるための初期設定 — Redmine.JP](http://redmine.jp/tech_note/first-step/admin/)
252
+- ログイン
253
+| URL | http://redmine.example.com/ (redmine.conf で設定した URL) |
254
+| --- | --- |
255
+| User | admin |
256
+| Password | admin |
257
+
258
+## 設定
259
+- 「管理 - 設定」から各項目を変更。
260
+- 表示
261
+ - 日付の形式: yyyy-mm-dd
262
+ - 時刻の形式: hh:mm (24時制)
263
+- チケットトラッキング
264
+ - 現在の日付を新しいチケットの開始日とする: チェック外す
265
+ - 進捗の算出方法: チケットのステータスに連動
266
+- メール通知
267
+ - 送信元メールアドレス: admin@redmine.example.com
268
+ - メールのフッタ: http://redmine.example.com/my/account
269
+- リポジトリ
270
+ - 参照用キーワード: 「*」を追加。(参照用キーワード無しでリビジョンとチケットを関連づける)
271
+
272
+## トラッカー
273
+- 「機能, サポート, バグ」に順序を変更。
274
+
275
+## チケットのステータス
276
+- ステータス更新後、「進捗率の更新」をクリック。
277
+| ステータス | 進捗率 | 終了したチケット |
278
+| --- | --- | --- |
279
+| 新規 | | |
280
+| 進行中 | 50 | |
281
+| 解決 | 100 | v |
282
+| フィードバック | 70 | |
283
+| 終了 | 100 | v |
284
+| 却下 | 100 | v |
285
+
286
+# プラグイン
287
+- [GitHub:yukkyna/redmine-export-project-data](https://github.com/yukkyna/redmine-export-project-data)
288
+ - プロジェクト一式をファイルとしてエクスポートする。
289
+ - エクスポート
290
+```
291
+# cd /var/lib/redmine/
292
+# RAILS_ENV=production rake 'project_data:export[identifier,destdir]'
293
+```
294
+ - インポート
295
+```
296
+# cd /var/lib/redmine/
297
+# cp -R destdir/files/ .
298
+# chown -R apache. files/
299
+# chcon -Rh -t httpd_sys_content_t files/
300
+# cat destdir/identifier.sql | mysql -u user_redmine -p db_redmine
... ...
\ No newline at end of file
Linux/SELinux.md
... ...
@@ -0,0 +1 @@
1
+~~#include(SELinux,notitle)~~
... ...
\ No newline at end of file
Linux/SSH.md
... ...
@@ -0,0 +1,77 @@
1
+[[_TOC_]]
2
+
3
+# 公開鍵ファイル作成
4
+```
5
+$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
6
+Enter file in which to save the key (/home/you/.ssh/id_rsa): (そのままエンターを押す)
7
+Enter passphrase (empty for no passphrase): (パスフレーズを入力)
8
+Enter same passphrase again: (パスフレーズ確認)
9
+```
10
+
11
+- [Generating SSH keys - User Documentation](https://help.github.com/articles/generating-ssh-keys/)
12
+
13
+# 公開鍵ファイルを配置
14
+```
15
+# su user1
16
+$ cd ~
17
+$ mkdir ~/.ssh
18
+$ chmod 700 ~/.ssh
19
+$ vi ~/.ssh/authorized_keys (公開鍵ファイルの内容を書き込み)
20
+$ chmod 644 ~/.ssh/authorized_keys
21
+$ restorecon -Rv ~/.ssh/
22
+```
23
+
24
+# sshd_config
25
+- /etc/ssh/sshd_config (抜粋)
26
+```
27
+#Protocol 2
28
+Protocol 2
29
+
30
+#PermitRootLogin yes
31
+PermitRootLogin no
32
+
33
+#PasswordAuthentication yes
34
+#PermitEmptyPasswords no
35
+PasswordAuthentication no
36
+PermitEmptyPasswords no
37
+```
38
+- sshd を再起動した後、別ターミナルでログイン確認。<br />
39
+root でログインしているターミナルを終了すると、設定に問題があった場合、修正できなくなるため。
40
+ - CentOS7
41
+```
42
+# systemctl restart sshd.service
43
+```
44
+ - CentOS6
45
+```
46
+# service sshd restart
47
+```
48
+
49
+# ポートフォワード
50
+- Windows クライアントのローカルポートに対するアクセスを Linux サーバのリモートポートへ転送する。
51
+- [Win32-OpenSSH](https://github.com/PowerShell/Win32-OpenSSH) のインストール (Chocolatey)
52
+```
53
+> cinst -y openssh
54
+```
55
+- 設定ファイル %UserProfile%/.ssh/config
56
+```
57
+host Host1
58
+ user user1
59
+ hostname host1.domain1
60
+ port 22
61
+ identityfile ~/.ssh/id_rsa.user1
62
+ LocalForward 5901 host1.domain1:5900
63
+
64
+host Host2
65
+ user user2
66
+ hostname host2.domain2
67
+ port 22
68
+ identityfile ~/.ssh/id_rsa.user2
69
+ LocalForward 5902 host2.domain2:5900
70
+```
71
+- 接続 (PowerShell 上から)
72
+```
73
+> ssh -F "C:\Users\user1\.ssh\config" Host1
74
+```
75
+- 切断
76
+```
77
+$ exit
... ...
\ No newline at end of file
Linux/Samba.md
... ...
@@ -0,0 +1,209 @@
1
+[[_TOC_]]
2
+
3
+# インストール
4
+- Linux マシンをホストとして公開する場合
5
+```
6
+# yum install samba
7
+```
8
+- Windows 上の共有フォルダを Linux マシンにマウントする場合は追加のパッケージが必要
9
+```
10
+# yum install samba-client cifs-utils
11
+```
12
+
13
+# ユーザ設定
14
+- Samba用ユーザの確認
15
+```
16
+# pdbedit -L
17
+```
18
+- 既存のLinuxユーザに対しSambaで接続するためのパスワードを追加する。
19
+```
20
+# pdbedit -a -u <ユーザ名>
21
+```
22
+
23
+# グループ設定
24
+- 共有フォルダ管理グループ(SmbAdmin)を作成し、既存ユーザ user1 を SmbAdmin へ追加
25
+```
26
+# groupadd SmbAdmin
27
+# usermod -G SmbAdmin -a user1
28
+```
29
+- グループ SmbUsers に属しているユーザすべてに共有フォルダへのアクセスを許可する場合
30
+```
31
+# groupadd SmbUsers
32
+# usermod -G SmbUsers -a <ユーザ名>
33
+```
34
+
35
+# 共有用フォルダ
36
+- 共有フォルダ自体はオーナーとなるユーザはなし(nobody)。
37
+- SmbUsers グループに属するユーザは読み書き可能。
38
+- 管理グループ(SmbAdmin)に属するユーザがファイル作成/削除できるよう既定の拡張ファイル属性を設定。
39
+```
40
+# cd /home
41
+# mkdir Shared
42
+# chown nobody:SmbUsers Shared
43
+# chmod 777 Shared
44
+# setfacl -m d:g:SmbAdmin:rwx /home/Shared
45
+```
46
+
47
+- [8.2. Setting Access ACLs](https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-acls-setting.html)
48
+- [8.3. Setting Default ACLs](https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s1-acls-setting-default.html)
49
+
50
+# 設定
51
+- /etc/samba/smb.conf (抜粋)
52
+```
53
+[global]
54
+ unix charset = UTF-8
55
+ dos charset = CP932
56
+; display charset = UTF-8
57
+ wide links = yes
58
+ follow symlinks = yes
59
+ unix extensions = no
60
+ smb ports = 445
61
+ map to guest = Bad User
62
+; max protocol = SMB3
63
+
64
+ workgroup = WORKGROUP
65
+ hosts allow = 127. 192.168.0. 10.8.0.
66
+
67
+ security = user
68
+
69
+; CUPS を無効化
70
+ printing = bsd
71
+
72
+[homes]
73
+ browseable = no
74
+ writable = yes
75
+ valid users = %U
76
+
77
+[Shared]
78
+ path = /home/Shared
79
+ read only = no
80
+ browseable = yes
81
+ force group = SmbUsers
82
+ force create mode = 664
83
+ force directory mode = 775
84
+ valid users = <ユーザ1>, <ユーザ2>, @SmbUsers
85
+; samba 4.x で share modes は廃止
86
+; share modes = yes
87
+ dos filetimes = yes
88
+```
89
+- Windows 10 1709 は「max protocol = SMB2」を指定しないと接続に失敗する。(CentOS6, samba 3.6.23)
90
+
91
+# サービス設定
92
+
93
+## CentOS 6
94
+```
95
+# chkconfig --list smb
96
+# chkconfig smb on
97
+# chkconfig --list smb
98
+# service smb restart
99
+# chkconfig --list nmb
100
+# chkconfig nmb on
101
+# chkconfig --list nmb
102
+# service nmb restart
103
+```
104
+
105
+## CentOS 7
106
+```
107
+# systemctl enable smb nmb
108
+# systemctl restart smb nmb
109
+```
110
+
111
+# ファイアウォール設定
112
+
113
+## CentOS 6
114
+1. 「システム/管理/ファイアーウォール」を起動。
115
+```
116
+# system-config-firewall
117
+```
118
+1. 「カスタマイズ」を選択。
119
+1. 「Samba」「Sambaクライアント」にチェックを入れる。
120
+1. 「閉じる」を選択。
121
+1. 「OK」を選択。
122
+1. ファイアウォール設定を変更する旨の警告が出るので「はい」を選択。
123
+1. IPv6 を無効にしていると ip6tables の設定に失敗した旨のエラーメッセージが表示されるが、iptables については設定されている。
124
+
125
+## CentOS 7
126
+- OpenVPN 経由でのアクセスを許可
127
+- /etc/firewalld/services/samba-vpn.xml
128
+```xml
129
+<?xml version="1.0" encoding="utf-8"?>
130
+<service>
131
+ <short>Samba-VPN</short>
132
+ <description>This option allows you to access and participate in Windows file and printer sharing networks. You need the samba package installed for this option to be useful.</description>
133
+ <port protocol="tcp" port="445"/>
134
+ <destination ipv4="192.168.0.0/24"/>
135
+</service>
136
+```
137
+- サービス登録
138
+```
139
+# firewall-cmd --permanent --add-service=samba-vpn
140
+# firewall-cmd --reload
141
+```
142
+
143
+# SELinux設定
144
+
145
+## CentOS 6
146
+- ユーザホームディレクトリのアクセスを許可<br />
147
+Allow Samba to share users home directories.
148
+```
149
+# setsebool -P samba_enable_home_dirs 1
150
+```
151
+- 共有フォルダの読み書きを許可<br />
152
+Allow samba to share any file/directory read/write.
153
+```
154
+# setsebool -P samba_export_all_rw 1
155
+```
156
+
157
+## CentOS 7
158
+```
159
+# setsebool -P samba_enable_home_dirs 1
160
+# setsebool -P samba_export_all_rw 1
161
+# chcon -t samba_share_t /home/Shared
162
+```
163
+
164
+# Windows PC 上の共有フォルダをマウント
165
+- コマンド
166
+```
167
+# mount -t cifs -o username=<Windowsのアカウント名> //<WindowsマシンのIPアドレス>/<フォルダ> <マウントポイント>
168
+```
169
+- エラー対応
170
+ - エラーメッセージ
171
+```
172
+# mount -f cifs username=user1 //WinPC1/Shared /mnt/WinPC1_Shared/
173
+mount: 間違ったファイルシステムタイプ、不正なオプション、
174
+ //WinPC1/Shared のスーパーブロックが不正、コードページまたは
175
+ ヘルパープログラムの未指定、或いは他のエラー
176
+ (for several filesystems (e.g. nfs, cifs) you might
177
+ need a /sbin/mount.<type> helper program)
178
+ In some cases useful info is found in syslog - try
179
+ dmesg | tail or so
180
+# dmesg | tail
181
+CIFS VFS: cifs_mount failed w/return code = -22
182
+```
183
+ - 原因と対策<br />
184
+cifs-utils パッケージがインストールされていないので、インストールする。
185
+```
186
+# yum install cifs-utils
187
+```
188
+- リンク
189
+ - [Windows上のファイルにLinuxからアクセスするには(mount.cifs編) - @IT](http://www.atmarkit.co.jp/flinux/rensai/linuxtips/a004mountcifs.html)
190
+ - [FedoraでSambaマウントする方法 - Kerosoft : Modus Operandi](http://mo.kerosoft.com/0150)
191
+ - [UNIX系備忘録 | お勉強の軌跡](http://extra.pxt.jp/studylog/ja/unix/index.html)
192
+ - [CentOS5の小技](http://tomo.ac/goodstream/rhel/centos/tips5.html)
193
+
194
+# リンク
195
+- [Windowsファイルサーバー構築(Samba)](http://centossrv.com/samba.shtml) @ [CentOSで自宅サーバー構築](http://centossrv.com/)
196
+- [Sambaサーバ構築](http://d.hatena.ne.jp/Kimura/20110912/p1) @ [Kimura.Memo](http://d.hatena.ne.jp/Kimura/)
197
+- [エレクトリック・ボディ・ビート: Unable to connect to CUPS server localhost:631](http://roserogue.blogspot.jp/2008/08/unable-to-connect-to-cups-server.html)
198
+ - [Samba のエラー](http://d.hatena.ne.jp/umonist/20071101) @ [パソコン・メモメモ備忘録](http://d.hatena.ne.jp/umonist/)
199
+ - エラーメッセージ対応。
200
+```
201
+getpeername failed. Error was Transport endpoint is not connected
202
+getpeername failed. Error was 通信端点が接続されていません
203
+```
204
+ - smb.conf<br />
205
+プリンタを使用しない場合、printing を cups から bsd へ変更する。
206
+```
207
+printing = bsd
208
+```
209
+- [Samba 4によるWindowsネットワーク構築:ITpro](http://itpro.nikkeibp.co.jp/article/COLUMN/20131018/511929/)
... ...
\ No newline at end of file
Linux/VNC.md
... ...
@@ -0,0 +1,154 @@
1
+[[_TOC_]]
2
+----
3
+# パッケージ追加
4
+- GNOME のインストール
5
+<!--- # yum grouplist hidden | grep -i gnome (グループ名確認)-->
6
+<!--- 汎用デスクトップ(GNOMEデスクトップ)-->
7
+<!--- # yum groupinstall "汎用デスクトップ(GNOMEデスクトップ)"-->
8
+<!--- # yum grouplist | grep -i "x window" (グループ名確認)-->
9
+<!--- X Window System-->
10
+```
11
+# yum groupinstall "デスクトップ" "X Window System"
12
+```
13
+
14
+- vnc-server のインストール
15
+```
16
+# yum install tigervnc-server xinetd
17
+```
18
+
19
+- vnc クライアントのインストール
20
+```
21
+# yum install tigervnc
22
+```
23
+ - Ctrl+Alt+Del シグナルの送信<br />
24
+F8 でメニューを出して「Send Ctrl-Alt-Del」を選択する。
25
+
26
+# gdm
27
+- /etc/gdm/custom.conf (抜粋)
28
+```
29
+[security]
30
+AllowRoot=false
31
+AllowRemoteRoot=false
32
+
33
+[xdmcp]
34
+Enable=true
35
+
36
+[greeter]
37
+IncludeAll=false
38
+Exclude=root
39
+```
40
+
41
+- [Bug 723708 – gdm can neither exclude from nor add to login users generated by the system](https://bugzilla.redhat.com/show_bug.cgi?id=723708)
42
+
43
+# xinetd
44
+- /etc/xinetd.d/vnc
45
+```
46
+service vnc-1280x1024x16
47
+{
48
+ disable = no
49
+ type = UNLISTED
50
+ port = 5900
51
+ socket_type = stream
52
+ wait = no
53
+ user = nobody
54
+ group = tty
55
+ server = /usr/bin/Xvnc
56
+ server_args = -inetd -query localhost -once -SecurityTypes None -geometry 1280x1024 -depth 16
57
+ only_from = 192.168.0.0/24 10.8.0.0/24
58
+ log_on_failure += USERID
59
+}
60
+```
61
+- xinetd の再起動
62
+ - CentOS 7
63
+```
64
+# systemctl restart xinetd.service
65
+```
66
+ - CentOS 6
67
+```
68
+# service xinetd restart
69
+```
70
+
71
+# xrdp
72
+- Windows クライアントから RDP で CentOS サーバにアクセス可能。
73
+- インストール (EPEL)
74
+```
75
+# yum install -y xrdp
76
+```
77
+- サービス登録
78
+```
79
+# systemctl enable xrdp
80
+# systemctl start xrdp
81
+```
82
+
83
+# ファイアウォール設定
84
+- CentOS 7
85
+```
86
+# firewall-cmd --permanent --add-service=vnc-server
87
+# firewall-cmd --permanent --add-service=ms-wbt
88
+# firewall-cmd --reload
89
+```
90
+
91
+<!---** ファイアウォール [#vnc_firewall]-->
92
+<!---- ファイアウォール設定変更-->
93
+<!--- # system-config-firewall-->
94
+<!---|~キー|~操作|h-->
95
+<!---|~Tab|次の項目|-->
96
+<!---|~Space|選択|-->
97
+<!---- 「カスタマイズ > (転送) > その他のポート」で「5900/tcp」を追加。-->
98
+
99
+# SSHポート転送
100
+- SSHポート転送を通すことでファイアウォールを開けなくても接続できる。
101
+ - SSHポート転送を使う場合、接続元IPアドレスがサーバのIPアドレスとなるので、only_fromでサーバIPアドレスを許可しておく。
102
+ - ログ確認
103
+```
104
+# tail /var/log/messages
105
+```
106
+
107
+## TeraTerm での設定例
108
+1. 「設定 - SSH転送」を選択。
109
+1. 「追加」ボタンをクリック。
110
+1. 転送設定
111
+| 向き | ローカルのポート |
112
+| --- | --- |
113
+| ローカルのポート | 任意(既存のサービスと衝突しないこと) |
114
+| リッスン | localhost |
115
+| リモート側ホスト | サーバのIPアドレスまたはネットワーク名 |
116
+| ポート | 5900 |
117
+1. 「OK」ボタンをクリック。
118
+1. 「リモートの(X)アプリケーションをローカルのXサーバに表示する」はチェックする必要なし。
119
+1. 「OK」ボタンをクリック。
120
+1. 「設定 - 設定の保存」で「TERATERM.INI」として保存。
121
+
122
+## PortForwarder での設定例
123
+- [PortForwarder](http://toh.fuji-climb.org/pf/JP/)
124
+
125
+1. 適当なフォルダにzipファイルの内容を展開する。
126
+```
127
+%ProgramFiles%/PortForwarder/
128
+```
129
+1. 設定ファイルと秘密鍵ファイルを1つのフォルダに入れる。
130
+```
131
+%USERPROFILE%/.ssh/
132
+```
133
+1. 設定ファイル pf_config.txt 例
134
+```
135
+# ホスト別設定
136
+
137
+host RemoteRepo1
138
+ user user1
139
+ hostname repo1.example.com
140
+ port 22
141
+ identityfile id_rsa.repo1.example.com
142
+ LocalForward 5901 repo1:5900
143
+
144
+host RemoteRepo2
145
+ user user2
146
+ hostname repo2.example.com
147
+ port 22
148
+ identityfile id_rsa.repo2.example.com
149
+ LocalForward 5902 repo2:5900
150
+```
151
+ - [OpenSSH SSH client configuration files](http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config)
152
+
153
+# バグ
154
+- [After installing the NVIDIA driver, tigervnc doesn't work in Centos 7. · Issue #39 · TigerVNC/tigervnc · GitHub](https://github.com/TigerVNC/tigervnc/issues/39)
... ...
\ No newline at end of file
Linux/Virtualization.md
... ...
@@ -0,0 +1,324 @@
1
+[[_TOC_]]
2
+----
3
+# KVM パッケージインストール
4
+- CentOS 7
5
+```
6
+# yum groupinstall "Virtualization Host" "Virtualization Client"
7
+```
8
+- CentOS 6
9
+```
10
+# yum groupinstall "Virtualization" "Virtualization Client" "Virtualization Platform" "Virtualization Tools"
11
+```
12
+- [Windows Virtio Drivers](https://fedoraproject.org/wiki/Windows_Virtio_Drivers)
13
+```
14
+# wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
15
+# yum install virtio-win
16
+# cp /usr/share/virtio-win/virtio-win.iso .
17
+```
18
+- ISOイメージのコピーではなくシンボリックリンクだと「Permission denied」になる?
19
+- Windows Server 2012 R2 のインストーラはサブディレクトリの探索はしてくれないので各々のドライバが配置してあるサブディレクトリまで指定する必要がある。
20
+
21
+# NIC のブリッジ設定
22
+- 物理マシン-仮想マシン間の接続を「NAT接続」にすると、物理マシンのネットワークから仮想マシンのサービスにアクセスすることができないため、物理マシン-仮想マシン間の接続には「ブリッジ接続」を使う。
23
+
24
+## CentOS 7
25
+- NIC デバイス確認。<br />
26
+物理 NIC デバイス名は環境によって変わる。
27
+```
28
+# nmcli dev
29
+DEVICE TYPE STATE CONNECTION
30
+virbr0 bridge connected virbr0
31
+enp1s0 ethernet connected enp1s0
32
+lo loopback unmanaged --
33
+virbr0-nic tun unmanaged --
34
+```
35
+- 自動的に追加される virbr0 は初期状態だと NAT モードなので、削除してブリッジモードの仮想デバイスを追加。
36
+```
37
+# nmcli dev delete virbr0
38
+# nmcli con delete virbr0
39
+# nmcli con add type bridge ifname br0
40
+# nmcli con modify bridge-br0 bridge.stp no
41
+# nmcli con modify bridge-br0 ipv4.method manual ipv4.address "192.168.1.2/24" ipv4.gateway "192.168.1.1" ipv4.dns 8.8.8.8 ipv4.dns-search example.com
42
+```
43
+- 物理 NIC デバイスを bridge デバイスに追加。
44
+```
45
+# nmcli con add type bridge-slave ifname enp1s0 master br0
46
+# nmcli con del enp1s0; reboot
47
+```
48
+- 再起動後の状態確認。
49
+```
50
+# nmcli dev
51
+DEVICE TYPE STATE CONNECTION
52
+br0 bridge connected bridge-br0
53
+virbr0 bridge connected virbr0
54
+enp1s0 ethernet connected bridge-slave-enp1s0
55
+vnet0 tun connected vnet0
56
+lo loopback unmanaged --
57
+virbr0-nic tun unmanaged --
58
+
59
+# nmcli dev show br0
60
+GENERAL.DEVICE: br0
61
+GENERAL.TYPE: bridge
62
+GENERAL.HWADDR: XX:XX:XX:XX:XX:XX (実 NIC の MAC と同じ)
63
+GENERAL.MTU: 1500
64
+GENERAL.STATE: 100 (connected)
65
+GENERAL.CONNECTION: bridge-br0
66
+GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/1
67
+IP4.ADDRESS[1]: 192.168.1.2/24
68
+IP4.GATEWAY: 192.168.1.1
69
+IP4.ROUTE[1]: dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 425
70
+IP4.ROUTE[2]: dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 425
71
+IP4.DNS[1]: 8.8.8.8
72
+IP6.ADDRESS[1]: XXXX::XXXX:XXXX:XXXX:XXXX/64
73
+IP6.GATEWAY: --
74
+IP6.ROUTE[1]: dst = ff00::/8, nh = ::, mt = 256, table=255
75
+IP6.ROUTE[2]: dst = fe80::/64, nh = ::, mt = 256
76
+IP6.ROUTE[3]: dst = fe80::/64, nh = ::, mt = 425
77
+
78
+# nmcli dev show virbr0
79
+GENERAL.DEVICE: virbr0
80
+GENERAL.TYPE: bridge
81
+GENERAL.HWADDR: YY:YY:YY:YY:YY:YY
82
+GENERAL.MTU: 1500
83
+GENERAL.STATE: 100 (connected)
84
+GENERAL.CONNECTION: virbr0
85
+GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/3
86
+IP4.ADDRESS[1]: 192.168.122.1/24
87
+IP4.GATEWAY: --
88
+IP4.ROUTE[1]: dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0
89
+IP6.GATEWAY: --
90
+
91
+# nmcli dev show enp1s0
92
+GENERAL.DEVICE: enp1s0
93
+GENERAL.TYPE: ethernet
94
+GENERAL.HWADDR: XX:XX:XX:XX:XX:XX (br0 の MAC と同じ)
95
+GENERAL.MTU: 1500
96
+GENERAL.STATE: 100 (connected)
97
+GENERAL.CONNECTION: bridge-slave-enp1s0
98
+GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveConnection/2
99
+WIRED-PROPERTIES.CARRIER: on
100
+IP4.GATEWAY: --
101
+IP6.GATEWAY: --
102
+IP6.ROUTE[1]: dst = ff00::/8, nh = ::, mt = 256, table=255
103
+
104
+# nmcli con
105
+NAME UUID TYPE DEVICE
106
+bridge-br0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX bridge br0
107
+bridge-slave-enp1s0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX ethernet enp1s0
108
+virbr0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX bridge virbr0
109
+vnet0 XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX tun vnet0
110
+```
111
+
112
+- [TipsAndTricks/BridgeAndNmcli - CentOS Wiki](https://wiki.centos.org/TipsAndTricks/BridgeAndNmcli)
113
+- [CentOS7.2でブリッジインタフェースを作る - hosiiのメモ帳](http://hosii.net/?p=446)
114
+
115
+## CentOS 6
116
+- /etc/sysconfig/network-scripts/ifcfg-eth0
117
+```
118
+# Physical NIC 0
119
+DEVICE=eth0
120
+ONBOOT=yes
121
+HWADDR=xx:xx:xx:xx:xx:xx
122
+BOOTPROTO=none
123
+BRIDGE=br0
124
+NM_CONTROLLED=no
125
+```
126
+- /etc/sysconfig/network-scripts/ifcfg-br0
127
+```
128
+# Virtual Bridge 0
129
+DEVICE=br0
130
+TYPE=Bridge
131
+ONBOOT=yes
132
+BOOTPROTO=static
133
+IPADDR=192.168.0.10 # 物理マシンのIPアドレス
134
+PREFIX=24
135
+GATEWAY=192.168.0.1 # 物理マシン/仮想マシン共通のゲートウェイ
136
+DNS1=192.168.0.1
137
+DOMAIN=TakeAsh.net
138
+NM_CONTROLLED=no
139
+```
140
+
141
+## 仮想環境用ネットワーク設定
142
+- 設定ファイル
143
+```
144
+/usr/share/libvirt/networks/default.xml
145
+```
146
+- [libvirt: Network XML format](https://libvirt.org/formatnetwork.html)
147
+- ネットワーク一覧表示
148
+```
149
+# virsh net-list --all
150
+```
151
+- 設定内容表示
152
+```
153
+# virsh net-dumpxml default
154
+```
155
+- 自動起動を無効化
156
+```
157
+# virsh net-autostart default --disable
158
+```
159
+- 自動起動を有効化
160
+```
161
+# virsh net-autostart default
162
+```
163
+- 手動起動
164
+```
165
+# virsh net-start default
166
+```
167
+
168
+# 仮想マシンマネージャの起動
169
+- root 権限が必要。
170
+- Gnome: アプリケーション - システムツール - 仮想マシンマネージャー
171
+- bash: virt-manager
172
+
173
+# インストールメディアおよび仮想マシンイメージファイルの場所
174
+- /var/lib/libvirt/images/
175
+- シンボリックリンクで別の場所に変更する場合、該当ディレクトリだけでなく上位のディレクトリも qemu ユーザでアクセスできないとエラーとなる。
176
+```
177
+# chown root. /mnt/ExtDisk/
178
+# chown root. /mnt/ExtDisk/VirtImages/
179
+# chmod 755 /mnt/ExtDisk/
180
+# chmod 755 /mnt/ExtDisk/VirtImages/
181
+# mv /var/lib/libvirt/images/ /var/lib/libvirt/_images
182
+# ln -s /mnt/ExtDisk/VirtImages/ /var/lib/libvirt/images
183
+```
184
+
185
+- [symlink - Virt-install can't find image behind symbolic link - Stack Overflow](https://stackoverflow.com/questions/%33%36%36%35%37%35%33%36)
186
+
187
+# 仮想マシン定義ファイルの場所
188
+- /etc/libvirt/qemu/
189
+
190
+# 新規仮想マシン作成
191
+
192
+## 詳細設定
193
+- ステップ5/5の「インストール前に設定をカスタマイズする」チェックボックスにチェックを入れておくと、下記項目の設定ができる。
194
+- 各項目毎に「適用」ボタンを押さないと、次の項目に変えた時にデフォルトに戻ってしまう。
195
+
196
+## CPU
197
+- クライアント版(非サーバ版) Windows では CPU を2ソケットまでしか認識しないため、2コア以上を割り当てるにはトポロジーの手動設定が必要。
198
+> 例) 2 CPU 各 3 Core 設定
199
+| CPU | 現在の割り当て | 6 |
200
+| --- | --- | --- |
201
+| トポロジー | ソケット数 | 2 |
202
+| | コア数 | 3 |
203
+| | スレッド数 | 1 |
204
+<
205
+- 「Configuration」は、「Copy host CPU configuration」ボタンをクリックすることで物理マシンの CPU 構成をコピーできる。
206
+
207
+## 仮想 NIC のモデル
208
+| モデル名 | スピード |
209
+| --- | --- |
210
+| e1000 | 10/100/1000 Mbps |
211
+| rtl8139 | 10/100 Mbps |
212
+- デフォルトは「rtl8139」になっている。
213
+
214
+## ディスプレイVNC
215
+- 種類: Spice
216
+ - VNC だとサウンドが再生されない。
217
+
218
+# 仮想マシンの操作(コマンドライン)
219
+
220
+## 仮想マシンの一覧表示
221
+```
222
+# virsh list --all
223
+```
224
+
225
+## 仮想マシンを起動
226
+```
227
+# virsh start <仮想マシン名>
228
+```
229
+
230
+## 仮想マシンをシャットダウン
231
+```
232
+# virsh shutdown <仮想マシン名>
233
+```
234
+
235
+## 仮想マシンのディスクイメージファイルを変更
236
+- 対象の仮想マシンはシャットダウンしていること。
237
+- edit で、<source file='~'/> を <新イメージファイル名> に修正, 保存する。
238
+- edit の操作は vi 。
239
+```
240
+# virsh list --all
241
+# mv <元イメージファイル名> <新イメージファイル名>
242
+# virsh edit <仮想マシン名>
243
+```
244
+
245
+## 仮想マシンの定義ファイルの表示
246
+```
247
+# virsh dumpxml <仮想マシン名>
248
+```
249
+
250
+## 仮想マシンの削除
251
+- 仮想マシン定義ファイルは削除されるが、ディスクイメージファイルは削除されない。
252
+```
253
+# virsh undefine <仮想マシン名>
254
+```
255
+
256
+## 仮想マシンの自動起動
257
+- ホスト起動時に自動起動させる
258
+```
259
+# virsh autostart <仮想マシン名>
260
+```
261
+- 自動起動設定確認
262
+```
263
+# ls /etc/libvirt/qemu/autostart/
264
+```
265
+- 自動起動の解除
266
+```
267
+# virsh autostart --disable <仮想マシン名>
268
+```
269
+
270
+# サウンド出力
271
+- [Audio output](https://fedoraproject.org/wiki/How_to_debug_Virtualization_problems#Audio_output)
272
+- /etc/libvirt/qemu.conf
273
+```
274
+vnc_allow_host_audio = 1
275
+```
276
+- ディスプレイ表示に VNC ではなく Spice を使う。
277
+
278
+# エラー対応
279
+
280
+## virt-who を起動しようとして失敗する
281
+- 起動時に毎回エラーメッセージが表示される。
282
+```
283
+Démarrage de virt-who : Traceback (most recent call last):
284
+File "/usr/share/virt-who/virt-who.py", line 33, in <module>
285
+from subscriptionmanager import SubscriptionManager, SubscriptionManagerError
286
+File "/usr/share/virt-who/subscriptionmanager.py", line 24, in <module>
287
+import rhsm.connection as rhsm_connection
288
+ImportError: No module named rhsm.connection
289
+[FAILED]
290
+```
291
+- 原因: パッケージのミスで本来不要な virt-who がインストールされてしまう。
292
+- 対処: virt-who のアンインストール。
293
+```
294
+yum erase virt-who
295
+```
296
+- [0006342: service virt-who won't start without python-rhsm - CentOS Bug Tracker](http://bugs.centos.org/view.php?id=6342)
297
+
298
+# リンク
299
+- [KVM](http://www.linux-kvm.org/)
300
+
301
+- [Red Hat Enterprise Linux - Red Hat Customer Portal](https://access.redhat.com/knowledge/docs/Red_Hat_Enterprise_Linux/)
302
+ - [仮想化管理ガイド - Red Hat Customer Portal](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Administration_Guide/index.html)
303
+ - [仮想化スタートガイド - Red Hat Customer Portal](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Getting_Started_Guide/index.html)
304
+ - [仮想化セキュリティガイド - Red Hat Customer Portal](https://access.redhat.com/knowledge/docs/ja-JP/Red_Hat_Enterprise_Linux/6/html/Virtualization_Security_Guide/index.html)
305
+
306
+- [libvirt: The virtualization API](http://libvirt.org/)
307
+ - [Bindings for other languages](http://libvirt.org/bindings.html)
308
+ - [CPAN:Sys-Virt](http://search.cpan.org/dist/Sys-Virt)
309
+
310
+- [Karesansui Project](http://karesansui-project.info/) Xen/KVM Virtualization Management Application
311
+ - https://github.com/karesansui
312
+
313
+- [KVMで始めるプライベート・クラウドへの第一歩:連載|gihyo.jp … 技術評論社](http://gihyo.jp/admin/serial/01/ibm_kvm)
314
+ - [第3回 KVMのネットワーク構成](http://gihyo.jp/admin/serial/01/ibm_kvm/0003)
315
+ - [第5回 KVM仮想マシンの操作](http://gihyo.jp/admin/serial/01/ibm_kvm/0005)
316
+
317
+- [【仮想化道場】 Linux標準のサーバー仮想化機能「KVM」を試す -クラウド Watch](http://cloud.watch.impress.co.jp/docs/column/virtual/20110606_450502.html)
318
+
319
+- [第3回 仮想化環境KVMのシステム管理、監視 - Think IT](http://thinkit.co.jp/story/2010/12/15/1916)
320
+
321
+- [らくらくクラウド運用術 - Linux KVM+KickStart+Puppetで作る環境構築自動化システム:ITpro](http://itpro.nikkeibp.co.jp/article/COLUMN/20130723/493372/)
322
+
323
+- [わすれないうちにメモしよう](http://d.hatena.ne.jp/kt_hiro/)
324
+ - [KVM ゲストOSに物理ディスクを直接接続する](http://d.hatena.ne.jp/kt_hiro/20120114/1326471240)
... ...
\ No newline at end of file
Linux/iptables.md
... ...
@@ -0,0 +1,88 @@
1
+[[_TOC_]]
2
+
3
+# 設定書き出し
4
+- [showSettings.zip](showSettings.zip)
5
+```bash
6
+#!/bin/bash
7
+
8
+FILE=settings.`date +"%Y-%m-%d"`.txt
9
+
10
+rm -rf ${FILE}
11
+echo "* filter" >> ${FILE}
12
+iptables -L --line-numbers -t filter >> ${FILE}
13
+echo >> ${FILE}
14
+echo "* nat" >> ${FILE}
15
+iptables -L --line-numbers -t nat >> ${FILE}
16
+```
17
+
18
+# ポート転送
19
+- ポート転送を有効にする。<br />
20
+/etc/sysctl.conf
21
+```
22
+net.ipv4.ip_forward = 1
23
+```
24
+
25
+- ポート転送ルール追加スクリプト
26
+[addForwarding.zip](addForwarding.zip)
27
+```bash
28
+#!/bin/bash
29
+
30
+scriptname="${0##*/}"
31
+
32
+if [ $# -lt 3 ]; then
33
+ cat << EOL
34
+説明: iptables にポート転送設定を追加する。
35
+使用法: ${scriptname} <ForwardingPort> <TargetAddress> <TargetPort>
36
+EOL
37
+ exit 1
38
+fi
39
+
40
+host=`ifconfig | grep "inet addr" | head -n 1`
41
+if [[ "${host}" =~ addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) ]]; then
42
+ host=${BASH_REMATCH[1]}
43
+else
44
+ echo "ホストのIPアドレスが取得できませんでした。"
45
+ exit 1
46
+fi
47
+
48
+fport="$1"
49
+taddr="$2"
50
+tport="$3"
51
+
52
+# 転送ルール追加
53
+iptables -t nat -A PREROUTING -m tcp -p tcp --dst ${host} --dport ${fport} -j DNAT --to-destination ${taddr}:${tport}
54
+iptables -t nat -A POSTROUTING -m tcp -p tcp --dst ${taddr} --dport ${tport} -j SNAT --to-source ${host}
55
+iptables -A FORWARD -m tcp -p tcp --dst ${taddr} --dport ${tport} -j ACCEPT
56
+
57
+# 戻りパケットを許可(1回追加してあれば、更に追加する必要なし)
58
+#iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
59
+
60
+# MTU が異なるサブネット間で転送する場合用
61
+#iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
62
+
63
+# FORWARD/REJECT をルールの最後に移動
64
+reject=`iptables -L FORWARD --line-numbers -t filter | grep "REJECT" | head -n 1`
65
+if [[ "${reject}" =~ ^([0-9]+).*reject-with(.*) ]]; then
66
+ line=${BASH_REMATCH[1]}
67
+ option=${BASH_REMATCH[2]}
68
+ iptables -A FORWARD -j REJECT --reject-with ${option}
69
+ iptables -D FORWARD ${line}
70
+else
71
+ echo "FORWARD の REJECT を移動できませんでした。"
72
+ exit 1
73
+fi
74
+```
75
+
76
+## リンク
77
+- [iptablesで特定のポートを別のホストへ転送する方法 - Kerosoft : Modus Operandi](http://mo.kerosoft.com/0203)
78
+- [CentOS iptablesによるパケットフィルタ](http://www.unix-power.net/linux/iptables.html)
79
+- [iptables のテーブル表示 と アクセス許可/natの例 - ihirokyの日記](http://d.hatena.ne.jp/ihiroky/20100104/1262590176)
80
+
81
+# ポート開放
82
+- INPU チェインの指定位置に接続許可ルールを挿入する。
83
+```
84
+# iptables -I INPUT <ルール番号> -m state --state NEW -p tcp --dport <ポート番号> -j ACCEPT
85
+```
86
+
87
+# リンク
88
+- [iptablesの設定方法|さくらインターネット公式サポートサイト](https://help.sakura.ad.jp/app/answers/detail/a_id/2423)
... ...
\ No newline at end of file
Linux/phpMyAdmin.md
... ...
@@ -0,0 +1,23 @@
1
+[[_TOC_]]
2
+
3
+# インストール
4
+- EPEL リポジトリ
5
+```
6
+# yum install php phpMyAdmin
7
+```
8
+
9
+- 設定ファイル
10
+ - /etc/phpMyAdmin/
11
+ - /etc/httpd/conf.d/phpMyAdmin.conf
12
+
13
+- インストール先
14
+ - /usr/share/phpMyAdmin/
15
+
16
+# 初期設定
17
+- ブラウザで http://localhost/phpMyAdmin/setup/ を開く。
18
+ - EPEL からインストールした場合、config.inc.php ってどこに保存されてるんだろ?<br />
19
+config フォルダ作っても中のファイルは更新されないし。
20
+
21
+# リンク
22
+- [phpMyAdmin](http://www.phpmyadmin.net/)
23
+ - ドキュメント [英語](https://phpmyadmin.readthedocs.org/) / [日本語](https://phpmyadmin.readthedocs.org/ja/)
... ...
\ No newline at end of file
_Sidebar.md
... ...
@@ -2,6 +2,7 @@
2 2
- [[Perl|Perl/Home]]
3 3
- [[JavaScript|JavaScript/Home]]
4 4
- [[Windows|Windows/Home]]
5
+ - [[Linux|Linux/Home]]
5 6
- [[Game|Game/Home]]
6 7
- [[Virtual-On|Game/VirtualOn/Home]]
7 8
- [[PSOBB|Game/PSOBB/Home]]