Difference between revisions of "Give an lxc container an external ip address"
From MyWiki
(Created page with "https://www.techrepublic.com/article/how-to-set-up-a-bridge-for-lxd-containers/<br> <source lang="text"> lxc launch images:centos/8 cent8 lxc list lxc config device add cent8...") |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | https://www.techrepublic.com/article/how-to-set-up-a-bridge-for-lxd-containers/<br> | + | https://www.techrepublic.com/article/how-to-set-up-a-bridge-for-lxd-containers/<br><br> |
| + | '''Once the bridge is set up run this:'''<br> | ||
<source lang="text"> | <source lang="text"> | ||
lxc launch images:centos/8 cent8 | lxc launch images:centos/8 cent8 | ||
| Line 9: | Line 10: | ||
lxc stop cent8 | lxc stop cent8 | ||
lxc start cent8 | lxc start cent8 | ||
| + | </source> | ||
| + | <br> | ||
| + | '''Example of netplan file on host server'''<br> | ||
| + | <source lang="text"> | ||
| + | # This file describes the network interfaces available on your system | ||
| + | # For more information, see netplan(5). | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | enp2s0: | ||
| + | dhcp4: no | ||
| + | # addresses: [192.168.0.17/24] | ||
| + | # gateway4: 192.168.0.1 | ||
| + | # nameservers: | ||
| + | # addresses: [8.8.8.8,8.8.4.4] | ||
| + | # routes: | ||
| + | # - to: 10.8.0.0/24 | ||
| + | # via: 10.8.0.74 | ||
| + | |||
| + | bridges: | ||
| + | br0: | ||
| + | interfaces: [enp2s0] | ||
| + | addresses: [192.168.0.17/24] | ||
| + | gateway4: 192.168.0.1 | ||
| + | mtu: 1500 | ||
| + | nameservers: | ||
| + | addresses: [8.8.8.8] | ||
| + | parameters: | ||
| + | stp: true | ||
| + | forward-delay: 4 | ||
| + | |||
</source> | </source> | ||
Latest revision as of 09:38, 7 August 2021
https://www.techrepublic.com/article/how-to-set-up-a-bridge-for-lxd-containers/
Once the bridge is set up run this:
lxc launch images:centos/8 cent8 lxc list lxc config device add cent8 eth0 nic nictype=bridged parent=br0 name=eth0 lxc list lxc exec cent8 – /bin/bash lxc list lxc stop cent8 lxc start cent8
Example of netplan file on host server
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: no
# addresses: [192.168.0.17/24]
# gateway4: 192.168.0.1
# nameservers:
# addresses: [8.8.8.8,8.8.4.4]
# routes:
# - to: 10.8.0.0/24
# via: 10.8.0.74
bridges:
br0:
interfaces: [enp2s0]
addresses: [192.168.0.17/24]
gateway4: 192.168.0.1
mtu: 1500
nameservers:
addresses: [8.8.8.8]
parameters:
stp: true
forward-delay: 4