LXD menyediakan network default bernama lxdbr0, network profil ini memberikan antarmuka IP jaringan yang di sediakan oleh LXD. IP yang di dapat belum Disa di akses dari luar jaringan namun pastinya kita sulit untuk menjadikan profil network ini induk di akses dari luar.
Bagaimana caranya agar container pada LXD dapat di akses dari luar jaringan? Maka kita perlu menyamakan IP guest dengan host menggunakan MACVLAN yang di sediakan oleh LXD.
tanpa berlama” mari ke materi utama.
Install LXD Pada server anda (bagi anda yang baru meninstall server. Disini saya menggunakan Ubuntu 24.04 Live Server
$ apt install snap lxd -y
$. sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: no Do you want to configure a new storage pool? (yes/no) [default=yes]: yes Name of the new storage pool [default=default]: Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]: Create a new ZFS pool? (yes/no) [default=yes]: Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: Size in GiB of the new loop device (1GiB minimum) [default=30GiB]: Would you like to connect to a MAAS server? (yes/no) [default=no]: Would you like to create a new local network bridge? (yes/no) [default=yes]: What should the new bridge be called? [default=lxdbr0]: What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: Would you like the LXD server to be available over the network? (yes/no) [default=no]: Would you like stale cached images to be updated automatically? (yes/no) [default=yes]: Would you like a YAML “lxd init” preseed to be printed? (yes/no) [default=no]:
# Create and configure the new macvlan profile
$ lxc profile copy default macvlan-profile
$ lxc profile device remove macvlan-profile eth0
Output: Device eth0 removed from macvlan-profile
$ lxc profile device add macvlan-profile eth0 nic nictype=macvlan parent=enp2s0
Output: Device eth0 added to macvlan-profile# Launch a new container using the new profile
$ lxc launch ubuntu:jammy jammy2 –profile macvlan-profile
Creating jammy2Starting jammy2
# Show the macvlan-profile configuration
$ lxc profile show macvlan-profileconfig: {}description: Default LXD profiledevices: eth0: nictype: macvlan parent: enp2s0 type: nic root: path: / pool: default type: diskname: macvlan-profileused_by:- /1.0/instances/jammy2
# Show the LXC Containers’ IP address
$ lxc list -c n4
+——–+———————–+| NAME | IPV4 |+——–+———————–+| jammy1 | 10.248.108.184 (eth0) |+——–+———————–+| jammy2 | 192.168.50.170 (eth0) |+——–+———————–+
source link: https://luppeng.wordpress.com/2023/01/10/make-lxd-containers-visible-on-host-network/
source video: https://youtu.be/TmGvbXfwJEA?si=DdwaN9sl_7Lf9U3c
Leave a Reply