Skip to content

Instantly share code, notes, and snippets.

@umardx
Last active September 7, 2022 19:41
Show Gist options
  • Select an option

  • Save umardx/f3aa541595167cd93a5635d68660113d to your computer and use it in GitHub Desktop.

Select an option

Save umardx/f3aa541595167cd93a5635d68660113d to your computer and use it in GitHub Desktop.
Netplan PBR and Bridges

netplan config /etc/netplan/50-cloud-init.yaml

$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

network:
  version: 2
  ethernets:
    ens3:
      dhcp4: no
      dhcp6: no
  bridges:
    vs0:
      interfaces:
        - ens3
      dhcp4: no
      dhcp6: no
      addresses: [167.205.3.41/24]
      routes:
        - to: 0.0.0.0/0
          via: 167.205.3.1
          metric: 200
        - to: 0.0.0.0/0
          via: 167.205.3.1
          table: 100
        - to: 167.205.0.0/16
          via: 167.205.3.1
          table: 100
        - to: 10.0.0.0/8
          via: 167.205.3.1
          table: 100
      routing-policy:
        - from: 167.205.3.0/24
          table: 100
      nameservers:
        addresses: [167.205.23.1,167.205.3.1]
        search: [ARC.100.ac.id]

openvpn-client config /etc/openvpn/client/udx.conf

$ cat /etc/openvpn/client/udx.conf
.
.
.
script-security 2
route-up /etc/openvpn/fix_routes.sh

file /etc/openvpn/fix_routes.sh

$ cat /etc/openvpn/fix_routes.sh 
#!/bin/sh -x
/sbin/ip route del 0.0.0.0/1 via $route_vpn_gateway
/sbin/ip route del 128.0.0.0/1 via $route_vpn_gateway
/sbin/ip route add default via $route_vpn_gateway proto static metric 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment