Open Source How-To

You are here: Home > 4. Ubuntu 18.04 Server > การตั้งค่า network bridge interface บน ubuntu 18.04 server

การตั้งค่า network bridge interface บน ubuntu 18.04 server

 
 

บันทึกนี้ปรับปรุงล่าสุดเมื่อวันที่ 14-11-2561
ดูแลโดย WIBOON

  • เพื่อต่อไปจะทำ LXC/KVM/Xen/Containers virtualization ที่ติดต่อกับภายนอกได้
  • ตัวอย่างเมื่อตรวจสอบด้วยคำสั่ง ifconfig พบว่าได้ชื่อ network interface คือ enp0s25 เป็นต้น


1. ติดตั้งซอฟต์แวร์ bridge

sudo apt install bridge-utils


2. ตั้งค่า network interface โดยแก้ไขที่ไฟล์ /etc/netplan/01-netcfg.yaml

sudo nano /etc/netplan/01-netcfg.yaml

ตัวอย่าง ตั้ง interface ว่า br0 ให้เป็น IP 192.168.6.19 CIDR subnet /25

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s25:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      dhcp4: no
      dhcp6: no
      interfaces:
        - enp0s25
      addresses: [ 192.168.6.19/25 ]
      gateway4: 192.168.6.1
      nameservers:
          addresses:
              - "192.100.77.10"


3. สั่งให้มีผลทันที

sudo netplan apply


4. ตรวจสอบ ifconfig จะได้ผลประมาณนี้

br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.6.19  netmask 255.255.255.128  broadcast 192.168.6.127
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether c1:1c:ef:95:89:xx  txqueuelen 1000  (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
nach oben