rootfs 已經改好,不用進去 mknode tty..
stop 的時候就 lxc-stop --nokill
如果直接 lxc-stop ,就會hang住很久,然後有 input/output error
最後是 ref:https://l3net.wordpress.com/2013/08/25/debian-virtualization-lxc-network-isolation/
手動 啟動 bridge 才讓 lxc 的網路連通。
host:
# brctl addbr br0 # ifconfig br0 10.10.20.1/24 up然後 /var/lib/lxc/my1stcontainer/config:
# Template used to create this container: /usr/share/lxc/templates/lxc-debian # Parameters passed to the template: # For additional config options, please look at lxc.container.conf(5) #lxc.network.type = empty lxc.rootfs = /var/lib/lxc/my1stcontainer/rootfs # Common configuration lxc.include = /usr/share/lxc/config/debian.common.conf # Container specific configuration lxc.mount = /var/lib/lxc/my1stcontainer/fstab lxc.utsname = my1stcontainer lxc.arch = amd64 lxc.autodev = 1 lxc.kmsg = 0 lxc.network.type = veth lxc.network.link = br0 lxc.network.flags = up lxc.network.ipv4 = 10.10.20.10/24 lxc.network.ipv4.gateway = 10.10.20.1
lxc 的 /etc/network/interfaces:
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.10.20.10 netmask 255.255.255.0 gateway 10.10.20.1 nameserver 10.244.128.5奇怪的是 lxc 裡的 network/interfaces gateway, nameserver 好像沒五有用。default gateway 要設在 /var/lib/lxc/xxx/config 裡才行。
nameserver 沒有辦法設在 config,所以目前無解。
這樣設定後, host 加上 nat,lxc 就出的去了...
了解了,要是在 /var/lib/lxc/my1stcontainer/config 裡面設 ipv4 address, netmask. gateway 等等。
在 my1stcontainer 裡的 /etc/network/interfaces 的 ipaddress, netmask, gateway, dns-nameserver 等設定都會被忽略。
所以 /etc/resolv.conf 就不會依照 interfaces 的內容 update, ..
所以.. /var/lib/lxc/my1stcontainer/config 只要設定基本的就好...
lxc.network.type = veth lxc.network.link = lxcbr0 lxc.network.flags = up然後在 my1stcontainer 裡的 /etc/network/interfaces 就可以設得完整一點...
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.10.20.10 netmask 255.255.255.0 gateway 10.10.20.1 network 10.10.20.0 broadcast 10.10.20.25 dns-nameservers 10.244.128.5 10.244.128.6至於 手動啟動 br0 部份,也可以改在 host 的 /etc/network/interfaces 裡...
auto lxcbr0 iface lxcbr0 inet static address 10.10.20.1 netmask 255.255.255.0 bridge_ports dummy0
沒有留言:
張貼留言