Manage routing of multiple gateways and interfaces from a single VM

Post Reply
brid.surapol
Posts: 164
Joined: 11 Apr 2013, 11:43

Manage routing of multiple gateways and interfaces from a single VM

Post by brid.surapol »

https://synaptica.info/en/2021/06/16/ub ... ingola-vm/

Code: Select all

sudo apt install iproute2

Code: Select all

sudo vim /etc/iproute2/rt_tables
ใส่ 2 บรรทัดสุดท้าย

Code: Select all

800 800
801 801
name: eno1
ip address: 192.168.100.214
network: 192.168.100.0/22
gateway: 192.168.100.34
macaddress: 38:68:DD:31:5C:48

name: eno4
ip address: 192.168.30.14
network: 192.168.30.0/24
gateway: 192.168.30.1
macaddress: 38:68:DD:31:5C:4B


netplan .yaml

Code: Select all

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      addresses:
        - 192.168.100.214/22
      match:
        macaddress: 38:68:DD:31:5C:48
      mtu: 1500
      nameservers:
          addresses:
              - "8.8.8.8"
              - "203.113.7.130"
              - "203.113.5.130"
      set-name: eno1
      routes:
        - to: 0.0.0.0/0
          via: 192.168.100.34
          table: 801
      routing-policy:
        - from: 192.168.100.214
          table: 801
          priority: 200

    eno4:
      addresses:
        - 192.168.30.14/24
      gateway4: 192.168.30.1
      match:
        macaddress: 38:68:DD:31:5C:4B
      mtu: 1500
      nameservers:
        addresses:
            - "8.8.8.8"
            - "110.164.252.222"
            - "110.164.252.223"
      set-name: eno4
      routes:
        - to: 0.0.0.0/0
          via: 192.168.30.1
          table: 800
      routing-policy:
        - from: 192.168.30.14
          table: 800
          priority: 300
Post Reply

Return to “การใช้งาน Linux”