You are not logged in.

#1 2016-12-03 04:52:21

jesc516
Member
From: LI,NY
Registered: 2015-01-26
Posts: 72

assign local ip address to systemd-nspawn container

how can i assign a local 192.168.1.x ip address to a container?

i created a .network profile in /etc/systemd/network on the host, for the guest container. however i noticed the virtual network interface changed after i created the .network profile on the host and rebooted the container.


/etc/systemd/network/host0@if6.network

[network]# cat host0@if6.network 
[Match]
Name=host0@if6

[Network]
Address=192.168.1.100
LinkLocalAddressing=yes
Gateway=192.168.1.1

now ip addr shows: (notice the 7, used to be 6, prior to creating .network profile )

2: host0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

actually, the virutal network interface increments by 1 after every reboot

2: host0@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000

Offline

#2 2017-01-28 14:47:40

kaz17
Member
Registered: 2016-02-23
Posts: 2

Re: assign local ip address to systemd-nspawn container

Rename your .network file to 50-la-la-la.network in order to use it before one of these files:
/usr/lib/systemd/network/80-container-host0.network
/usr/lib/systemd/network/80-container-ve.network
/usr/lib/systemd/network/80-container-vz.network

Offline

Board footer

Powered by FluxBB