lxc配置网络,host与lxc通信

执行/etc/init.d/networing restart重启网络后会发现多了一个br0的网卡

cat /etc/init.d/networing

/etc/network/interfaces

auto br0

iface br0 inet dhcp

bridge_ports enp2s0

bridge_fd 0

bridge_maxwait 0

  • 配置容器的网络

容器的网络配置文件默认路径为/var/lib/lxc/{name}/config

lxc.network.type = veth
lxc.network.flags = up
# that's the interface defined above in host's interfaces file
lxc.network.link = br0
 
# name of network device inside the container,
# defaults to eth0, you could choose a name freely
# lxc.network.name = lxcnet0 
 
lxc.network.hwaddr = 00:FF:AA:00:00:01

然后在容器的/etc/network/interfaces/文件中添加

auto eth0 iface eth0 inet dhcp
 

或者:

在config中增加如下配置:

lxc.net.0.type 

你可能感兴趣的:(服务器,linux,网络,arm开发)