馬哥教育網絡班21期+第11周課程練習

1、詳細描述一次加密通訊的過程,結合圖示最佳。

291403304192811.jpg

  • 單向加密:只能加密,不能解密,提取數據指紋(特征碼),來保證數據的完整性,如上圖的第二步,單向加密的協議有MD5,SHA等

  • 非對稱加密:公鑰和私鑰成對出現,私鑰必須本機器保存,用公鑰加密的數據,只能使用與之配對兒的私鑰解密;反之亦然,數字簽名是私鑰加密特征碼,如上圖的第三步;實現對稱秘鑰交換,如上圖第五步

  • 對稱加密:加密和解密使用同樣的秘鑰,實現數據加密,產生對稱秘鑰,如上圖的第四步

2、描述創建私有CA的過程,以及為客戶端發來的證書請求進行辦法證書

  • openssl的配置文件:/etc/pki/tls/openssl.cnf,創建所需要的文件;

[root@centos CA]# ls
certs  crl  newcerts  private
[root@centos CA]# touch index.txt serial
[root@centos CA]# echo "01" >serial 
[root@centos CA]# cat serial 
01
[root@centos CA]# (umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 1024) 
Generating RSA private key, 1024 bit long modulus     私鑰cakey.pem
.++++++
....++++++
  • CA自簽證書;

[root@centos CA]# openssl  req -new -x509 -key /etc/pki/CA/private/cakey.pem -days 
3650 -out /etc/pki/CA/cacert.pem      cacert.pem 是CA證書,內含CA公鑰
  • 發證;

[root@localhost tmp]# (umask 077;openssl genrsa -out /tmp/test.key 1024)
Generating RSA private key, 1024 bit long modulus
.++++++
............++++++
e is 65537 (0x10001)
[root@localhost tmp]# openssl req -new -key /tmp/test.key -days 365 -out /tmp/test.csr 
證書請求
[root@localhost tmp]# scp /tmp/test.csr root@192.168.40.128:/tmp/
root@192.168.40.128's password: 
test.csr                                       100%  684     0.7KB/s   00:00  
[root@centos private]# openssl ca -in /tmp/test.csr -out /tmp/test.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
[root@centos CA]# cat index.txt serial
V170604033819Z01unknown/C=CN/ST=BJ/O=BJorg/OU=BJorg/CN=centos.localhost/emailAddress=admin@bat.com
02

3、描述DNS查詢過程以及DNS服務器類別

  • DNS:域名解析系統,使用tcp/53進行區域傳輸,udp/53進行查詢操作;根域名全球13臺服務器,頂級域名(國家級cn uk… ,通用級org com net…,反向域),二級域名,三級域名

  • DNS查詢方法:遞歸查詢(要求DNS直接給出域名對應的IP),迭代查詢(通常是發生在DNS服務器間,當請求的域名不再自己所負責的解析范圍內,便開始從根迭代直到查詢到相應解析為止)

  • DNS查詢過程:Client –> hosts文件 –> DNS Service–>Local Cache –> DNS Server (recursion) –> Server Cache –> iteration(迭代) –>其他DNS服務器

  • DNS服務器類別:主DNS(維護所負責解析的域內解析庫服務器,解析庫由管理維護),從DNS(從主DNS服務器或其它的從DNS服務器那里區域傳輸一份解析庫),緩存DNS服務器(為客戶端緩存客戶端曾經查詢的記錄,找不到時,DNS服務器去迭代查詢),轉發器(當請求的DNS記錄不在自己所負責的解析區域時,交給轉發器處理,轉發器去迭代查詢) 

4、搭建一套DNS服務器,負責解析magedu.com域名(自行設定主機名及IP)

  (1)、能夠對一些主機名進行正向解析和逆向解析;

[root@centos named]# host -t NS magedu.com 192.168.40.128
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
magedu.com name server centos.magedu.com.
[root@centos named]# host -t A www.magedu.com 192.168.40.128
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
www.magedu.com has address 192.168.50.128
[root@centos named]# host -t MX  mail.magedu.com 192.168.40.128
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
mail.magedu.com mail is handled by 10 192.168.40.128.magedu.com.
[root@centos named]# host -t CNAME  test.magedu.com 192.168.40.128
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
test.magedu.com is an alias for www.magedu.com.
[root@centos named]# host -t PTR  192.168.50.128  192.168.40.128
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
128.50.168.192.in-addr.arpa domain name pointer test.magedu.com.
[root@centos named]# cat /etc/named.conf
options {
listen-on port 53 { 192.168.40.128; };
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";
recursion yes;
/* 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";
};
zone "magedu.com" IN {
      type master;
    file "magedu.com.file";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
[root@centos named]# cat /var/named/magedu.com.file 
$TTL 1D
$ORIGIN magedu.com.
@IN SOA centos.magedu.com. admin.magedu.com. (
20168102053; serial
1D; refresh
1H; retry
1W; expire
3H ); minimum
IN NS centos
mail     IN MX 10 192.168.40.128
centosIN A192.168.40.128
mail    IN A     192.168.40.128
www     IN A    192.168.50.128
test1    IN  A      192.168.60.128
test    IN CNAME www
[root@centos named]# cat /var/named/50.168.192.arpa.file 
$TTL 1D
@IN SOA centos.magedu.com admin.magedu.com. (
201608102205; serial
1D; refresh
1H; retry
1W; expire
3H ); minimum
      IN NScentos.magedu.com.
128   IN   PTR       test.magedu.com.

  (2)、對子域cdn.magedu.com進行子域授權,子域負責解析對應子域中的主機名;

  • 主域需要在(1)的基礎上添加子域的NS記錄并注釋掉主域的 /etc/named.conf 的

//include "/etc/named.root.key";
        IN NS    centos
cdn.magedu.com.    IN NS centos.cdn.magedu.com.  子域名稱服務器
centos.cdn.magedu.com. IN A 192.168.40.130       子域名稱服務器主機記錄
mail     IN MX 10 192.168.40.128
centos  IN A    192.168.40.128
mail    IN A     192.168.40.128
www     IN A    192.168.50.128
test1    IN  A      192.168.60.128
test    IN CNAME www
  • 子域注釋掉主配置文件的include "/etc/named.root.key";,添加 轉發主域區域,正常配置自己的區域解析數據庫文件即可

zone "magedu.com" IN {
 type forward;
 forwarders{192.168.40.128;};
};
  • 測試

[root@centos ~]# host -t A www.magedu.com 192.168.40.130 使用子域DNS解析父域域名
Using domain server:
Name: 192.168.40.130
Address: 192.168.40.130#53
Aliases: 
www.magedu.com has address 192.168.50.128
[root@centos ~]# host -t A www.cdn.magedu.com 192.168.40.130 使用子域解析自己區域的主機記錄
Using domain server:
Name: 192.168.40.130
Address: 192.168.40.130#53
Aliases: 
www.cdn.magedu.com has address 119.20.20.20
[root@centos ~]# host -t A www.cdn.magedu.com 192.168.40.128 使用父域DNS解析子域域名
Using domain server:
Name: 192.168.40.128
Address: 192.168.40.128#53
Aliases: 
www.cdn.magedu.com has address 119.20.20.20

  (3)、為了保證DNS服務系統的高可用性,請設計一套方案,并寫出詳細的實施過程

為了實現DNS服務系統的高可用性建議搭建一主多從,一主一從,下面是一主一從實施過程:

  • 假設192.168.30.128為主DNS為magedu.com提供域名解析服務,構建主DNS服務器

zone "magedu.com" IN {
      type master;
    file "magedu.com.file";
};
[root@centos ~]# cat /var/named/magedu.com.file 
$TTL 1D
$ORIGIN magedu.com.
@IN SOA centos.magedu.com. admin.magedu.com. (
20168102053; serial
1D; refresh
1H; retry
1W; expire
3H ); minimum
IN NS centos
cdn.magedu.com.    IN NS centos.cdn.magedu.com.
centos.cdn.magedu.com. IN A 192.168.40.130
mail     IN MX 10 192.168.40.128
centosIN A192.168.40.128
mail    IN A     192.168.40.128
www     IN A    192.168.50.128
test1    IN  A      192.168.60.128
test    IN CNAME www
  • 假設192.168.30.130為主DNS為magedu.com提供域名解析服務,構建從DNS服務器

zone "magedu.com" IN {
      type slave;
       masters {192.168.40.128;};
    file "slaves/slave.magedu.com.file"; 自動在主DNS服務器下載解析庫文件
};
[root@centos slaves]# ls
slave.magedu.com.file
[root@centos slaves]# cat slave.magedu.com.file 
$ORIGIN .
$TTL 86400; 1 day
magedu.comIN SOAcentos.magedu.com. admin.magedu.com. (
2988232869 ; serial
86400      ; refresh (1 day)
3600       ; retry (1 hour)
604800     ; expire (1 week)
10800      ; minimum (3 hours)
)
NScentos.magedu.com.
$ORIGIN magedu.com.
cdnNScentos.cdn
$ORIGIN cdn.magedu.com.
centosA192.168.40.130
$ORIGIN magedu.com.
centosA192.168.40.128
mailA192.168.40.128
MX10 192.168.40.128
testCNAMEwww
test1A192.168.60.128
wwwA192.168.50.128
  • 測試使用192.168.40.130

[root@centos slaves]# vim /etc/resolv.conf 
[root@centos slaves]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.40.128  主DNS
nameserver 192.168.40.130  從DNS
[root@centos slaves]# host -t A www.magedu.com
www.magedu.com has address 192.168.50.128
[root@centos ~]# service named stop
Stopping named:                                            [  OK  ] 關閉主DNS服務
[root@centos slaves]# host -t A www.magedu.com
www.magedu.com has address 192.168.50.128
[root@centos slaves]# host -t A www.magedu.com
www.magedu.com has address 192.168.50.128

原創文章,作者:Snoo,如若轉載,請注明出處:http://www.www58058.com/31955

(0)
SnooSnoo
上一篇 2016-08-15 12:06
下一篇 2016-08-15 12:07

相關推薦

  • 第四周作業

    1、復制/etc/skel目錄為/home/tuser1,要求/home/tuser1及其內部文件的屬組和其它用戶均沒有任何訪問權限。 [root@localhost ~]# cp /etc/skel /home/tuser1 [root@localhost ~]# chmod -R&nb…

    Linux干貨 2017-01-18
  • vim文本操作、例行性工作、腳本編程_第六周練習(01)

    vim文本操作 Q1:復制/etc/rc.d/rc.sysinit文件至/tmp目錄,將/tmp/rc.sysinit文件中的以至少一個空白字符開頭的行的行首加#; [root@promote /]# cp /etc/rc.d/rc.sysinit /tmp/ [root@promote /]# l…

    Linux干貨 2016-12-18
  • 編譯安裝httpd2.4-centos6

    centos6編譯安裝httpd2.4 默認是不支持,需自己動手進行編譯 apr-1.4+ apr-util-1.4+ :需提前進行編譯安裝這兩個軟件 編輯安裝httpd2.4實例 1、#安裝開發包 [root@www ~]# yum groupinstall “Development Tools” “Server Pla…

    Linux干貨 2017-05-17
  • N26_第三周

    1、列出當前系統上所有已經登錄的用戶的用戶名。同一個用戶多次登錄,只顯示一次 [root@node1 ~]# who |cut -d ‘ ‘ -f 1 | sort-u root zhh   2、取出最后登錄到當前系統的用戶的相關信息 [root@node1 ~]# id `last | head -1 | cut -d&#…

    Linux干貨 2017-05-26
  • linux文件目錄詳解

    linux目錄結構   (且看且不看) 歷史上 /usr和 /etc文件夾下既保存靜態文件,也保存可變文件,后來有了/var層次結構,/usr下面的可變文件被轉移到/var下面。因而/usr現在可以只讀的方式掛載(如果它在單獨的文件系統上)。 /etc下的可變文件早已轉移到/var,因為技術上允許/ 根是系統內核啟動后掛載的第一個分區,掛載到根上的…

    Linux干貨 2017-05-31

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-08-17 15:04

    寫的很好,排版也很棒,加油

欧美性久久久久