lxc-network
Manage LXC virtual network devices
TLDR
List all available networks
Show the configuration of a specific network
Add a running instance to a specific network
Create a new managed network
Set a bridge interface of a specific network
Disable NAT for a specific network
SYNOPSIS
lxc-network {start|stop|restart|create|destroy}
PARAMETERS
start
Brings up a network bridge.
stop
Brings down a network bridge.
restart
Restarts a network bridge (stop then start).
create
Creates a new network bridge.
destroy
Deletes a network bridge. WARNING: can cause network issues if containers are using the bridge.
The name of the network bridge to operate on (e.g., lxcbr0, mybridge).
--address
Specifies the IP address for the bridge (used with create).
--netmask
Specifies the netmask for the bridge (used with create).
--dhcp-range
Specifies the DHCP range for the bridge (used with create).
--with-dhcpns
Creates a private network namespace for DHCP (used with create).
DESCRIPTION
The `lxc-network` command provides a central interface for managing network configurations within LXC (Linux Containers). It allows users to create, modify, and delete network bridges used by LXC containers. This command greatly simplifies the process of setting up networking for containers by abstracting away the complexities of manually configuring network interfaces and bridges.
The main purpose is to manage bridges used by LXC. Bridges facilitate network communication between containers and the host system, as well as between containers themselves. `lxc-network` enables creation of bridges, defines IP addresses, DHCP ranges, and other critical network settings. By using this tool, users can ensure consistent and reproducible network configurations for their containers, making container deployments and management more efficient and reliable. It supports creating default lxcbr0, and new custom bridge networks for advanced network isolation and separation.
CAVEATS
Deleting a bridge that is in use by containers can cause network connectivity issues for those containers.
Ensure appropriate network configurations are applied when creating new bridges, considering IP address ranges, and potential conflicts.
Some features might depend on the available kernel modules and networking tools.
EXAMPLES
Create a network bridge named `mybridge`:
`lxc-network create mybridge --address 10.0.3.1 --netmask 255.255.255.0 --dhcp-range 10.0.3.2,10.0.3.254`
Start the bridge `mybridge`:
`lxc-network start mybridge`
Stop the bridge `mybridge`:
`lxc-network stop mybridge`
Destroy the bridge `mybridge`:
`lxc-network destroy mybridge`
NETWORK CONFIGURATION FILES
Bridge configuration can be configured in /etc/lxc/default.conf or /etc/default/lxc.
The `lxc-net` service utilizes these config files for creating the default bridge lxcbr0 during the system boot. This service must be enabled.
HISTORY
The `lxc-network` command was developed as part of the LXC project to simplify network management for containers. It evolved alongside LXC itself, becoming an essential tool for creating and managing network bridges in a containerized environment. It originally started from shell scripts, with the aim of removing complexity from network bridge creation.