LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

lxc-network

manages networks for LXD containers and VMs

TLDR

List all networks
$ lxc network list
copy
Show network configuration
$ lxc network show [network_name]
copy
Show runtime state and addresses of a network
$ lxc network info [network_name]
copy
Create a new managed bridge
$ lxc network create [network_name]
copy
Create a bridge with a specific subnet and NAT
$ lxc network create [network_name] ipv4.address=[10.10.10.1/24] ipv4.nat=true ipv6.address=none
copy
Create a macvlan network on a host interface
$ lxc network create [network_name] --type=macvlan parent=[eth0]
copy
Attach an instance to a network
$ lxc network attach [network_name] [instance_name] [eth0]
copy
Detach an instance from a network
$ lxc network detach [network_name] [instance_name]
copy
Add a host interface to the bridge
$ lxc network set [network_name] bridge.external_interfaces=[eth1]
copy
Disable NAT
$ lxc network set [network_name] ipv4.nat=false
copy
List DHCP leases handed out by a network
$ lxc network list-leases [network_name]
copy
Edit the full configuration in an editor
$ lxc network edit [network_name]
copy

SYNOPSIS

lxc network subcommand [[remote:]network] [args] [options]

DESCRIPTION

lxc network manages networks for LXD containers and virtual machines. Managed network types include bridge (default), macvlan, sriov, ovn and physical. It can create and configure networks, attach them to instances or profiles, and inspect leases and allocations.Configuration keys such as ipv4.address, ipv4.nat, ipv4.dhcp, ipv6.address, dns.domain and bridge.mtu are set at creation time or later with set.

PARAMETERS

--target member

Cluster member to act on (for create, get, set, show, info and others).
-p, --property
With get, set or unset: treat the key as a network property (such as description) rather than a config key.

SUBCOMMANDS

list [remote:]

List available networks. Supports --format (csv, json, table, yaml, compact) and --all-projects.
show network
Show network configuration as YAML.
info network
Show runtime information (addresses, traffic counters, bond/VLAN state).
create network [key=value...]
Create a new managed network. --type/-t sets the network type.
delete network
Delete a network.
rename network new-name
Rename a network.
edit network
Edit the network configuration as YAML.
get network key
Get a configuration value.
set network key=value...
Set configuration values.
unset network key
Remove a configuration key.
attach network instance [device] [interface]
Attach a network interface to an instance.
detach network instance [device]
Detach a network interface from an instance.
attach-profile / detach-profile network profile [device]
Attach or detach a network interface to/from a profile.
list-leases network
List DHCP leases.
list-allocations
List IP addresses in use across networks and instances.
acl, forward, load-balancer, peer, zone
Manage network ACLs, address forwards, load balancers, OVN peerings and DNS zones.

CAVEATS

Only managed networks can be configured; unmanaged host interfaces appear in the list but cannot be edited. Changing ipv4.address on a bridge in use disrupts connected instances. In Incus, the community fork of LXD, the same functionality is provided by incus network, and the separate LXC tools (lxc-start etc.) have no lxc-network command.

HISTORY

Managed networks and the lxc network command were introduced in LXD 2.3 (2016). Since 2023 LXD is developed by Canonical, while the Linux Containers community continues the codebase as Incus.

SEE ALSO

lxc(1), incus(1), lxc-start(1)

RESOURCES

Copied to clipboard
Kai