အပိုင်း ၁ မှာတုန်းကတော့ routing and switching အကြောင်းကိုရှင်းပြပေးခဲ့တာဖြစ်ပါတယ်။ အပိုင်း ၂ မှာတော့ dns အကြောင်းကို ရှင်းပြပေးပါမယ်။
Networking မှာ ကွန်ပျူတာတွေက နံပါတ် (IP Address) တွေနဲ့ပဲ စကားပြောကြပါတယ်။ ဒါပေမဲ့ လူတွေက နံပါတ်တွေကို မှတ်မိဖို့ ခက်ခဲပါတယ်။ 192.168.1.11 လို့ မှတ်ရတာထက် db-server လို့ မှတ်ရတာ ပိုလွယ်ပါတယ်။
ဒီပြဿနာကို ဖြေရှင်းဖို့ Linux မှာ DNS စနစ် ဘယ်လိုအလုပ်လုပ်သလဲဆိုတာကို လေ့လာသွားကြပါမယ်။
Local Way
Network တခုထဲမှာ ကွန်ပျူတာ A "192.168.1.10" နဲ့ ကွန်ပျူတာ B "192.168.1.11" ဆိုပြီး 2ခု ရှိတယ် ဆိုပါစို့။ A ကနေ B ကို "ping 192.168.1.11" လို့ ခေါ်လို့ရတယ်။ ဒါပေမဲ့ B မှာ database server တင်ထားတော့ IP နဲ့ မခေါ်ချင်ဘူး "ping db" လို့ နာမည်နဲ့ ခေါ်ချင်ရင် ဘာလုပ်ရမလဲ?
နည်းလမ်း ကတော့ ကွန်ပျူတာ A ကို database ဆိုတာ 192.168.1.11 ကိုပြောတာပါဆိုပြီး ကွန်ပျူတာ A ရဲ့ /etc/hosts ဖိုင်မှာ "192.168.1.11 db" ဆိုပြီး သွားရောက်သတ်မှတ်ပေးလိုက်ရပါမယ်။ ဒီလိုရေးလိုက်တာနဲ့ "ping db" လို့ ရိုက်လိုက်ရင် "ping 192.168.1.11"ကို အလိုလို သိသွားပါလိမ့်မယ်။
NOTE!
ဒီ/etc/hosts က သင့်စက်တစ်လုံးတည်းအတွက်ပဲ အလုပ်လုပ်ပါတယ်။ တခြားစက်တွေက db ဆိုတဲ့ နာမည်ကို သိမှာမဟုတ်ပါဘူး။
The Central Way: DNS Server
ကွန်ပျူတာ ၁ လုံး ၂ လုံးဆိုရင် host file သတ်မှတ်ဖို့ အဆင်ပြေပေမဲ့ ကွန်ပျူတာ အလုံး ၁၀၀ ရှိမယ် အလုံး ၁၀၀ လုံးမှာ server တွေရှိပြီး အသီးသီး ချိတ်ဆက်ချင်တယ်။ အဲ့လို ဖြစ်လာရင်တော့ တခုချင်းစီမှာ /etc/hosts လိုက်ရေးဖို့ မဖြစ်နိုင်တော့ပါဘူး။ IP တစ်ခု ပြောင်းသွားတာနဲ့ အကုန်လိုက်ပြင်ရမယ့် ဒုက္ခ ရောက်သွားပါလိမ့်မယ်။
ဒါကြောင့် IP နဲ့ နာမည်စာရင်းတွေကို မှာ ဗဟိုပြုပြီး သိမ်းထားမဲ့ Server (DNS Server) တလုံး တည်ဆောက်လိုက်မယ် ဆိုပါစို့ ။
DNS Server ကို ဘယ်လို ညွှန်ပေးမလဲ?
မိမိ ကွန်ပျူတာကို "နာမည်မသိရင် ဒီ DNS Server 192.168.1.100 မှာ သွားမေး" လို့ ပြောချင်ရင် /etc/resolv.conf ဖိုင်မှာ "nameserver 192.168.1.100" အာက်ပါအတိုင်း သတ်မှတ်ပေးရပါတယ်။
ဒါဆိုရင် ဘယ်လို အလုပ်လုပ် သွားမလဲ ဆိုတော့ ကိုယ့်စက်က မသိတဲ့ နာမည်တစ်ခုခု (ဥပမာ - db) တွေ့တာနဲ့ ပထဦးဆုံး host file မှာ ရှိလား ရှာမယ် မရှိရင် ဒီ DNS Server ကို လှမ်းမေးပြီး ခေါ်သွားပါလိမ့်မယ်။ ဒါပေမဲ့ host file မှာ ရော DNS Server မှာပါ မရှိခဲ့ဘူး ဆိုရင်တော့ အင်တာနက်ပေါ်က Public DNS (ဥပမာ - 8.8.8.8) တွေဆီ ဆက်မေးပြီး ခေါ်ယူပေးပါလိမ့်မယ်။
Change Priority
Priority အရ host ကို အရင် မေးမယ် ပြီးရင် DNS ပြီးရင် internet ဖြစ်ပါတယ်။ တကယ်လို့ မိမိက Priority ကို ပြောင်းလဲချင်တယ် ဆိုရင်ရော ? dns server ကို first priority ထားချင်တယ်ဆိုရင်တော့ /etc/nsswitch.conf
မှာ "hosts: dns files" အောက်ပါအတိုင်း ပြောင်းနိုင်ပါတယ်။
ဆိုလိုတာ ကတော DNS Server ကို အရင်မေးမယ်။ ပြီးမှ /etc/hosts ဖိုင်ကို ကြည့်ပါမယ်။
ဒါကြောင့် ပုံမှန်အားဖြင့် Local /etc/hosts ဖိုင်က DNS Server ထက် ပိုပြီး ဦးစားပေး (Priority) မြင့်ပါတယ်။
Domain Names & Search Domains
အင်တာနက်မှာ Domain တွေကို အဆင့်ဆင့် ခွဲခြားထားပါတယ်။ ဥပမာ - drive.google.com
- google.com (Root)
- .com (Top Level Domain)
- google (Domain)
- drive (Subdomain)
DNS Record Types
DNS Server ထဲမှာ သိမ်းဆည်းတဲ့ Data အမျိုးအစားတွေကတော့
- A Record → IPv4 Address
- AAAA Record → IPv6 Address
- CNAME Record → Alias (နာမည်ပွား)။ ဥပမာ - eat.com ကို ခေါ်ရင် hungry.com ဆီ ရောက်သွားတာမျိုး။
Testing Tools
ping, nslookup, dig တို့လို dns နဲ့ဆိုင်တဲ့ linux command တွေကိုလည်း သုံးကြည့်ကြဖို့အကြံပေးချင်ပါတယ်။
နိဂုံး
ဒါတွေကတော့ Linux Host တစ်ခုမှာ DNS ဘယ်လို အလုပ်လုပ်သလဲဆိုတဲ့ အခြေခံ သဘောတရားတွေ ဖြစ်ပါတယ်။ ဒီ Concept တွေကို နားလည်ထားရင် Network ပြဿနာတွေ ဖြေရှင်းတဲ့အခါ (Troubleshooting) မှာ အများကြီး အထောက်အကူ ပြုပါလိမ့်မယ်။
လက်တွေ့ စမ်းသပ်ချင်ရင်တော့ KodeKloud ရဲ့ linux labs မှာ ဝင်ရောက် လေ့ကျင့်နိုင်ပါတယ်။
Discussion
Join the conversation
How do you feel about this article?
Comments
Sign in to join the conversation
Sign in to be the first to comment!
Share Your Article
Share with your professional network
Recent Articles
Day 1 - Software Development ကို ပိုပြီးမြန်စေမယ့် CI/CD
Software တစ်ခုရေးပြီးပြီဆိုရင် "ငါ့စက်ထဲမှာတော့ အလုပ်လုပ်တယ်" ဆိုရုံနဲ့ မပြီးသေးပါဘူး။ User တွေသုံးမယ့် Server ပေါ်ရောက်...

Secure AWS ECR Github Action Using OIDC
Modern DevOps နှင့် Cloud Security တို့မှာ အဓိကဖြစ်လာသည့် Authentication System ယနေ့ခေတ် DevOps, Cloud Engineering, CI/C...

Manual vs Automated Infrastructure: Why "useradd" Still Matters in the Terraform Era
DevOps careerကို လျှောက်နေတဲ့သူတိုင်း Terraform၊ Ansible စတဲ့ Infrastructure as Code (IaC) tools တွေရဲ့ အလုပ်လုပ်နိုင်စွ...
From Surviving to Thriving
“AI ကြောင့် developer အလုပ်ပျောက်သွားမလား?” ဆိုတဲ့ မေးခွန်းကို Junior developer တိုင်း စဉ်းစားဖူးကြမှာပါ။ ဈေးကွက်အခြေအနေ...

AWS - Global Infra
AWS Global Infra AWS Global Infra & Service Type ဆိုတဲ့ ခေါင်းစဉ်နဲ့ ၂၀၂၅ ဒီဇင်ဘာမှာရေးထားဖူးတဲ့ article ကို အရင်ဆုံး ဖတ...

