This seem to be a recurring topic and as there are many resources on the internet, it is all old and dated.
I am trying to get my head around using netplan as that is the new way to set up a network in ubuntu 17.10.
I want to have a static ip set in a container using a bridge on the hostmachine so the container is accessible on the local lan.
The host have two nics and is configured to have a static ip address with one nic and a bridge.
The container is given the static ip but the problem was that the container was also picking up a DHCP ip address from the range 100 to 150.
I have edited the /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with network: {config: disabled}
I got it “solved” by also removing the 50-cloud-init.yaml, running netplan --debug generate and netplan apply.
After restarting the container everything seem ok with only the one static ip shown.
It also work by just removing the 50-cloud-init.yaml and restarting the container.
Everything seem fine but my question is: is this the “right” way to go about setting up a static ip?
/etc/netplan/01-netcfg.yaml, host machine1:
network:
version: 2
renderer: networkd
ethernets:
enp5s0:
addresses: [192.168.2.10/24]
gateway4: 192.168.2.1
dhcp4: false
nameservers:
addresses: [8.8.4.4,8.8.8.8]
enp6s0:
dhcp4: false
bridges:
br0:
interfaces: [enp6s0]
addresses: [192.168.2.12/24]
dhcp4: false
parameters:
stp: false
forward-delay: 0
/etc/netplan/01-netcfg.yaml, container test1:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses: [192.168.2.169/24]
gateway4: 192.168.2.1
dhcp4: false
nameservers:
addresses: [8.8.4.4,8.8.8.8]
```
I have a profile that use the bridge on the host:
```yaml
config: {}
description: Basic LXD profile
devices:
eth0:
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: default
type: disk
name: basic
used_by:
- /1.0/containers/test1
```