summaryrefslogtreecommitdiff
path: root/doc/forum/Using_ip_address_in_a_container/comment_2_520c00ed10ead57bc46940f98a2fae01._comment
blob: 78b7563aa0afe71003349fdef3eacd7b508e1d13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[[!comment format=mdwn
 username="Nicolas.Schodet"
 avatar="http://cdn.libravatar.org/avatar/0d7ec808ec329d04ee9a93c0da3c0089"
 subject="systemd-nspawn with its own network in the container"
 date="2017-10-05T20:10:10Z"
 content="""
If you use networkd, things are quite simple, you can use
`--network-zone=something` and it will create a bridge, add the host interface
to it and add an interface in the container. Default networkd configuration
will choose an IP network for the zone (it use the interface name to recognize
what must be done), use DHCP in the container, handle DHCP request on host and
route packets to the external interface. The bridge is automatically removed
when all containers are shut down.

Without networkd, you can create a bridge on the host in
`/etc/network/interface`:

    auto br0
    iface br0 inet static
        address 10.42.0.1
	netmask 255.255.0.0
	pre-up brctl addbr br0
	post-down brctl delbr br0
	bridge_fd 0

Then use the `--network-bridge=br0` option. It will add the host interface
automatically to the bridge and you need a way to configure the containers
interface, either using networkd or the traditional ifupdown.

"""]]