Last active
December 7, 2015 01:41
-
-
Save kkyouhei/a76a9722e3a6aadf7d41 to your computer and use it in GitHub Desktop.
webエンジニアが実践しておきたいネットワークプロトコル ref: http://qiita.com/kkyouhei/items/8719ff2f5e4dab169dfd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo yum -y install bind |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo cp /etc/named.conf{,.org} | |
$ sudo vim /etc/named.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 確認 Helloという内容が追加されていれば成功 | |
sudo cat /var/mail/ec2-user | |
From [email protected] Sun Nov 29 18:38:38 2015 | |
Return-Path: <[email protected]> | |
Received: from ip-XXX-XXX-XXX-XXX.ap-northeast-1.compute.internal (localhost [127.0.0.1]) | |
by ip-XXX-XXX-XXX-XXX.ap-northeast-1.compute.internal (8.14.4/8.14.4) with ESMTP id tATIccSd031046 | |
for <[email protected]>; Sun, 29 Nov 2015 18:38:38 GMT | |
Received: (from ec2-user@localhost) | |
by ip-XXX-XXX-XXX-XXX.ap-northeast-1.compute.internal (8.14.4/8.14.4/Submit) id tATIccjD031045 | |
for ec2-user@localhost; Sun, 29 Nov 2015 18:38:38 GMT | |
From: EC2 Default User <[email protected]> | |
Message-Id: <201511291838.tATIccjD031045@ip-XXX-XXX-XXX-XXX.ap-northeast-1.compute.internal> | |
Date: Sun, 29 Nov 2015 18:38:38 +0000 | |
To: [email protected] | |
User-Agent: Heirloom mailx 12.4 7/29/08 | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset=us-ascii | |
Content-Transfer-Encoding: 7bit | |
Hello | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ANSWER SECTIONに先ほどの設定が出ていればOK | |
# MXレコードが波及されたか確認するのは dig mail.example.com mx で確認出来る | |
$ dig mail.example.com | |
; <<>> DiG 9.8.3-P1 <<>> mail.example.com | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26357 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 6 | |
;; QUESTION SECTION: | |
;mail.example.com. IN A | |
;; ANSWER SECTION: | |
mail.example.com. 3600 IN A XXX.XXX.XXX.XXX | |
;; AUTHORITY SECTION: | |
example.com. 86265 IN NS 03.dnsv.jp. | |
example.com. 86265 IN NS 02.dnsv.jp. | |
example.com. 86265 IN NS 04.dnsv.jp. | |
example.com. 86265 IN NS 01.dnsv.jp. | |
;; ADDITIONAL SECTION: | |
01.dnsv.jp. 19035 IN A XXX.XXX.XXX.XXX | |
02.dnsv.jp. 15489 IN A XXX.XXX.XXX.XXX | |
03.dnsv.jp. 15390 IN A XXX.XXX.XXX.XXX | |
03.dnsv.jp. 12191 IN AAAA 2400:8500:3000::53 | |
04.dnsv.jp. 13134 IN A XXX.XXX.XXX.XXX | |
04.dnsv.jp. 48160 IN AAAA 2400:8500:3fff::53 | |
;; Query time: 36 msec | |
;; SERVER: 192.168.11.1#53(192.168.11.1) | |
;; WHEN: Sat Dec 5 12:31:33 2015 | |
;; MSG SIZE rcvd: 243 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vi /var/named/master.yahoo.co.jp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo /etc/init.d/named start | |
$ sudo chkconfig named on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo cp /etc/resolv.conf{,.org} | |
$ sudo vi /etc/resolv.conf | |
$ cat /etc/resolv.conf | |
; generated by /sbin/dhclient-script | |
search ap-northeast-1.compute.internal | |
nameserver 127.0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEVICE=eth0 | |
BOOTPROTO=dhcp | |
ONBOOT=yes | |
TYPE=Ethernet | |
USERCTL=yes | |
# DHCPでIPを取得時にyesだと/etc/resolv.confの値が更新されてしまう | |
PEERDNS=no | |
IPV6INIT=no | |
PERSISTENT_DHCLIENT=yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# メールを送る時の@以降の文字列 | |
myhostname = mail.example.comなど | |
# ドメイン名 | |
mydomain = example.com | |
# コメントになっているので#を外す | |
myorigin = $mydomain | |
# localhostだとローカル内からのメールの受信のみ可能なので全てのメールを受信可能にする | |
inet_interfaces = all | |
# ipv6を許可すると環境によってはエラーになるらしい | |
inet_protocols = ipv4 | |
# $mydomainを追加する | |
# mtaが@以降のドメインをmydestinationの値と比較して自分が受信するべきか判定に使うため、 | |
# 設定されていないと受信出来ない | |
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain | |
home_mailbox = Maildir/ # コメントになっているので#を外す |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$TTL 43200 | |
yahoo.co.jp. IN SOA help.yahoo.co.jp. ns01.yahoo.co.jp. ( | |
1 | |
21600 | |
7200 | |
1209600 | |
43200) | |
yahoo.co.jp. NS ns01.yahoo.co.jp. | |
ns01 A 216.58.220.206 # google.co.jpのIP | |
www A 216.58.220.206 # google.co.jpのIP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// named.conf | |
// | |
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS | |
// server as a caching only nameserver (as a localhost DNS resolver only). | |
// | |
// See /usr/share/doc/bind*/sample/ for example named configuration files. | |
// | |
options { | |
# 自身のリクエストから応答出来るようにするため | |
# listen on portにEC2のプライベートIPを追加 | |
listen-on port 53 { 127.0.0.1; XXX.XXX.XXX.XXX;}; | |
listen-on-v6 port 53 { ::1; }; | |
directory "/var/named"; | |
dump-file "/var/named/data/cache_dump.db"; | |
statistics-file "/var/named/data/named_stats.txt"; | |
memstatistics-file "/var/named/data/named_mem_stats.txt"; | |
# 外からの要求に答えられるようにするためanyに変更 | |
allow-query { any; }; | |
recursion yes; | |
dnssec-enable yes; | |
dnssec-validation yes; | |
dnssec-lookaside auto; | |
# 自分では名前解決出来なかった時にフォワードするDNSサーバのIPアドレス | |
# 8.8.8.8はGoogleが提供するDNS | |
forwarders { 8.8.8.8; 8.8.4.4; }; | |
forward only; | |
/* Path to ISC DLV key */ | |
bindkeys-file "/etc/named.iscdlv.key"; | |
managed-keys-directory "/var/named/dynamic"; | |
}; | |
logging { | |
channel default_debug { | |
file "data/named.run"; | |
severity dynamic; | |
}; | |
}; | |
zone "." IN { | |
type hint; | |
file "named.ca"; | |
}; | |
# yahoo.co.jpの問い合わせをmaster.yahoo.co.jpの中に記述されたIPで返却する | |
zone "yahoo.co.jp" IN { | |
type master; | |
file "master.yahoo.co.jp"; | |
}; | |
include "/etc/named.rfc1912.zones"; | |
include "/etc/named.root.key"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "送信テスト" | mail "[email protected]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment