lxc设置网络为公网IP

一、搭建网桥:

安装bridge-utils

apt-get install bridge-utils
添加网桥:
brctl addbr br0
配置网络
vim /etc/network/interface

auto eth0
  iface eth0 inet manual

auto br0
  iface br0 inet static
  address 192.168.1.104
  netmask 255.255.255.0
  gateway 192.168.1.1
  dns-nameservers 8.8.8.8
  bridge_ports eth0
重启网络:
/etc/init.d/networking restart

二、修改lxc配置

打开/var/lib/lxc/container_name/config文件,修改为:lxc.network.link=br0

打开/var/lib/lxc/container_name/rootfs/etc/network/interfaces,修改指定容器网络配置

修改创建新容器的默认配置,打开/etc/lxc/default.conf,修改为:lxc.network.link=br0

你可能感兴趣的:(lxc设置网络为公网IP)