การตั้งค่า Multiple IP Address ใน Netplan บน Ubuntu Server 25.10

การตั้งค่า Multiple IP Address ใน Netplan บน Ubuntu Server 25.10

การตั้งค่า Multiple IP Address บนระบบ Ubuntu Server ที่ใช้ Netplan เป็นวิธีการกำหนดให้ Network Interface เดียวสามารถมี IP Address ได้หลายหมายเลข เหมาะสำหรับงานเช่น

  • การให้บริการหลายเว็บไซต์ (Virtual Host)
  • การทำ Reverse Proxy / Load Balancer
  • การใช้หลาย Service บนเครื่องเดียว เช่น Web Server, API Server
  • การทำระบบ Lab หรือ Server สำหรับการเรียนการสอน

ด้านล่างเป็นแนวทางการตั้งค่าที่สามารถนำไปใช้งานได้จริง


1. ตรวจสอบชื่อ Network Interface

ก่อนเริ่มตั้งค่า ให้ตรวจสอบชื่อ interface ของเครื่อง

ip a
ตัวอย่างผลลัพธ์
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP>
ในตัวอย่างนี้ interface คือ
ens18
 

2. เปิดไฟล์ Netplan Configuration

ไฟล์ config มักอยู่ใน directory

/etc/netplan/
ตัวอย่างไฟล์
/etc/netplan/00-installer-config.yaml
แก้ไขไฟล์ด้วย
sudo nano /etc/netplan/00-installer-config.yaml
 

3. ตัวอย่างการตั้งค่า Multiple IP

ตัวอย่างกำหนด IP หลายตัวให้กับ interface เดียว

network:

    version: 2
    renderer: networkd

    ethernets:
        ens18:
             dhcp4: no
             addresses:
                  – 192.168.1.10/24
                  – 192.168.1.11/24
                  – 192.168.1.12/24
            routes:
                 – to: default
                    via: 192.168.1.1
             nameservers:
             addresses:
                 – 8.8.8.8
                 – 1.1.1.1

คำอธิบาย

Parameter ความหมาย
addresses กำหนด IP หลายตัว
routes Gateway
nameservers DNS

4. Apply Configuration

หลังแก้ไขไฟล์ ให้ Apply config

sudo netplan apply
หรือใช้ test mode
sudo netplan try

5. ตรวจสอบผลลัพธ์

ตรวจสอบว่า IP ถูกเพิ่มหรือไม่

ip a
ตัวอย่างผลลัพธ์
inet 192.168.1.10/24
inet 192.168.1.11/24
inet 192.168.1.12/24
 

6. ตัวอย่างใช้งานจริง (Server Production)

ตัวอย่าง Server ที่มีหลาย Service

Service IP
Web Server 192.168.1.10
API Server 192.168.1.11
n8n Automation 192.168.1.12

ข้อดี

  • แยก service ได้ชัดเจน
  • ใช้ firewall control ง่าย
  • ใช้ SSL certificate แยกได้

7. ตัวอย่าง Advanced (Public IP)

หาก Server มี Public IP หลายตัว เช่น

161.246.67.20
161.246.67.26
161.246.67.27
สามารถตั้งค่า
addresses:
     – 161.246.67.20/26
     – 161.246.67.26/26
     – 161.246.67.27/26
แล้วใช้ Apache หรือ Nginx แยก VirtualHost ตาม IP ได้

ตัวอย่าง Apache

<VirtualHost 161.246.67.27:80>
          ServerName n8n.example.com
</VirtualHost>

8. Tips สำหรับ SysAdmin

คำสั่งตรวจสอบ Network

ดู IP

ip addr
ดู routing
ip route
ดู DNS
systemd-resolve –status
 

สรุป

การตั้งค่า Multiple IP Address ด้วย Netplan มีข้อดีสำคัญคือ

  • ใช้ Server เครื่องเดียวทำหลาย Service
  • จัดการ Network ได้ยืดหยุ่น
  • รองรับงาน Infrastructure เช่น Reverse Proxy, Docker, Kubernetes

จึงเป็นเทคนิคพื้นฐานที่ System Administrator และ DevOps ควรใช้งานได้คล่องในระบบ Ubuntu Server



Write by SysAdmin Knowledge
https://www.sysadmin.in.th
April 3, 2026