🌐 Network Interfaces & Port Binding
May 17, 2026
💡 Network Interface ဆိုတာ computer ရဲ့ network card တွေပါ — physical (ethernet, wifi) နဲ့ virtual (loopback, docker, VPN) နှစ်မျိုးရှိတယ်။
Network Interface ဆိုတာဘာလဲ?
Network Interface က computer မှာ network ကို listen လုပ်နေတဲ့ connection point တစ်ခုပါ။ Hardware (physical card) ဖြစ်နိုင်တယ်၊ software (virtual) လဲ ဖြစ်နိုင်တယ်။ မင်း နားလည်ထားတာ မှန်ပါတယ်! Network card က တစ်ခုထက်ပိုနိုင်တယ် — cable သုံးတာ တစ်ခု၊ wifi သုံးတာ တစ်ခု၊ VM/container တွေမှာ virtual interface တွေ ထပ်ရှိတယ်။
Network Interface အမျိုးအစားများ
1️⃣ Physical Interfaces (Hardware)
Computer ရဲ့ တကယ့် network card တွေ:
- eth0, eth1 — Ethernet cable card (LAN cable ချိတ်တဲ့နေရာ)
- wlan0, wlan1 — WiFi wireless card
- enp0s3, wlp2s0 — Modern naming (predictable network names) ဥပမာ IP addresses: 192.168.1.100, 10.0.0.50, etc.
2️⃣ Virtual Interfaces (Software)
Software က ဖန်တီးထားတဲ့ virtual network cards:
- lo (loopback) — 127.0.0.1, "talk to myself", localhost
- docker0 — 172.17.0.1, Docker bridge network
- vethXXXX — Virtual ethernet pairs, container connections
- virbr0 — Virtual machine bridge (KVM/QEMU)
- tun0, tap0 — VPN tunnels (OpenVPN, WireGuard)
Network Interfaces ကြည့်နည်း
သင့် computer မှာ ဘာ network interface တွေ ရှိလဲ ကြည့်ရန်:
# Method 1: ip command (modern)
ip addr show
ip a # short form
# Method 2: ifconfig (traditional)
ifconfig
ifconfig -a # show all (including down)
# Method 3: nmcli (NetworkManager)
nmcli device status
ဥပမာ Output
1: lo: <LOOPBACK,UP>
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP>
inet 192.168.1.100/24
3: wlan0: <BROADCAST,MULTICAST,UP>
inet 192.168.1.101/24
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP>
inet 172.17.0.1/16
Port Binding နဿ့ Interfaces
Port binding က "ဘယ် interface(s) ပေါ်မှာ listen လုပ်မလဲ" ဆိုတာကို ထိန်းချုပ်တယ်။
Scenario 1: Specific Interface (127.0.0.1)
nerdctl run -p 127.0.0.1:8080:80 nginx
Port 8080 ကို loopback interface (127.0.0.1) တစ်ခုတည်းမှာ bind လုပ်တယ်။ ✅ ခေါ်လို့ရတယ်:
http://localhost:8080← localhost က 127.0.0.1 ကို resolve လုပ်တယ်http://127.0.0.1:8080← Direct loopback address ❌ ခေါ်လို့မရဘူး:http://192.168.1.100:8080← eth0 interface မှာ bind မလုပ်ထားလို့http://192.168.1.101:8080← wlan0 interface မှာ bind မလုပ်ထားလို့- External network ကနေ
Scenario 2: All Interfaces (0.0.0.0)
nerdctl run -p 8080:80 nginx
# Same as: -p 0.0.0.0:8080:80
Port 8080 ကို network interface အားလုံးမှာ bind လုပ်တယ်။ ✅ ခေါ်လို့ရတဲ့ နေရာအားလုံး:
http://localhost:8080← localhost → 127.0.0.1 → lo interface boundhttp://127.0.0.1:8080← Loopback (lo) interfacehttp://192.168.1.100:8080← Ethernet (eth0) interfacehttp://192.168.1.101:8080← WiFi (wlan0) interfacehttp://<public-ip>:8080← Public IP (firewall allow လုပ်ထားရင်)- Phone/tablet က same WiFi network ကနေ
- Internet ကနေ (external access setup လုပ်ထားရင်)
localhost ဆိုတာဘာလဲ?
🔍 localhost သည် hostname တစ်ခုဖြစ်ပြီး 127.0.0.1 IP address ကို ညွှန်းတယ်။ /etc/hosts ဖိုင်မှာ define လုပ်ထားတယ်။
/etc/hosts ဖိုင်
# /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ဒီကြောင့် browser/terminal မှာ "localhost" လို့ ရိုက်လိုက်ရင် automatically 127.0.0.1 ကို resolve လုပ်တယ်။
localhost က ဘာကြောင့် နှစ်ခုလုံးမှာ အလုပ်လုပ်လဲ?
- Browser က "localhost" ကို 127.0.0.1 အဖြစ် resolve လုပ်တယ်
- OS က 127.0.0.1:8080 ကို lo interface မှာ ရှာတယ်
- Case 1 (127.0.0.1:8080 bind): lo interface မှာ တိုက်ရိုက် bind လုပ်ထားလို့ အလုပ်လုပ်တယ်
- Case 2 (0.0.0.0:8080 bind): interface အားလုံးမှာ bind လုပ်ထားတယ် → lo လဲ ပါတယ် → အလုပ်လုပ်တယ်
⚡ 0.0.0.0 က special address ပါ — "interface အားလုံး" ကို ဆိုလိုတယ်။ lo (127.0.0.1) + eth0 (192.168.1.100) + wlan0 (192.168.1.101) + docker0 + အားလုံး!
လက်တွေ့ ဥပမာ
မင့် computer IP addresses:
- Loopback (lo): 127.0.0.1
- Ethernet (eth0): 192.168.1.100
- WiFi (wlan0): 192.168.1.101
Test 1: 127.0.0.1 Only Binding
# Run container
nerdctl run -d -p 127.0.0.1:8080:80 nginx
# Test from same machine
curl http://localhost:8080 # ✅ Works
curl http://127.0.0.1:8080 # ✅ Works
curl http://192.168.1.100:8080 # ❌ Connection refused
# Test from phone (same WiFi)
curl http://192.168.1.100:8080 # ❌ Connection refused
Test 2: All Interfaces Binding
# Run container
nerdctl run -d -p 8080:80 nginx
# Test from same machine
curl http://localhost:8080 # ✅ Works
curl http://127.0.0.1:8080 # ✅ Works
curl http://192.168.1.100:8080 # ✅ Works
curl http://192.168.1.101:8080 # ✅ Works
# Test from phone (same WiFi)
curl http://192.168.1.100:8080 # ✅ Works!
မှတ်ထားရမယ့် Key Points ⭐
- Network interface = Network card (physical or virtual) — network ကို listen လုပ်သူ
- Physical interfaces: eth0 (cable), wlan0 (wifi)
- Virtual interfaces: lo (loopback), docker0, veth (containers), virbr0 (VMs)
- localhost = hostname (/etc/hosts မှာ define) — 127.0.0.1 ကို resolve လုပ်တယ်
- 127.0.0.1 = Loopback IP — "talk to myself", lo interface
- 0.0.0.0 = All interfaces — lo + eth0 + wlan0 + အားလုံး
- -p 127.0.0.1:8080:80 → localhost:8080 ရတယ် (lo interface bound)
- -p 8080:80 → localhost:8080 + 192.168.x.x:8080 + အားလုံးရတယ် (all interfaces bound)
- localhost ဆိုတာ မပြောင်းဘူး — binding location က ပြောင်းတာပါ
- Security: 127.0.0.1 only binding က external access ကို block လုပ်တယ်
✅ မင့် နားလည်မှု မှန်ပါတယ်! Network card က တစ်ခုထက်ပိုနိုင်တယ် — physical (cable, wifi) + virtual (docker, VM, VPN)။ Port binding က "ဘယ် interface(s) မှာ listen မလဲ" ဆုံးဖြတ်ပေးတာပါ။