sudo brctl addbr lxcbr0 sudo ifconfig -a lxcbr0 lxcbr0 Link encap:Ethernet HWaddr b2:63:51:ae:XX:XX UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) sudo ifconfig lxcbr0 10.10.20.1/24 up sudo ifconfig -a lxcbr0 lxcbr0 Link encap:Ethernet HWaddr b2:63:51:ae:XX:XX inet addr:10.10.20.1 Bcast:10.10.20.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:38 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:8756 (8.5 KiB)
修改 /var/lib/lxc/mylxc/config:
#lxc.network.type = empty lxc.network.type = vnet lxc.network.link = lxcbr0 lxc.network.flags = up
啟動 lxc-start -n mylxc
這時候,host 的 iface 會多出一個 奇怪名子的 interface,跟 lxcbr0 bound 在一起..
host 上...
sudo ifconfig lxcbr0 Link encap:Ethernet HWaddr fe:0f:87:47:XX inet addr:10.10.20.1 Bcast:10.10.20.255 Mask:255.255.255.0 inet6 addr: fe80::fc83:faff:fe48:5849/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:16 errors:0 dropped:0 overruns:0 frame:0 TX packets:161 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1072 (1.0 KiB) TX bytes:27958 (27.3 KiB) veth3JU39Y Link encap:Ethernet HWaddr fe:0f:87:47:XX inet6 addr: fe80::fc0f:87ff:fe47:d33f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:56 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:648 (648.0 B) TX bytes:6440 (6.2 KiB)
用 brctl 來看...
sudo brctl show bridge name bridge id STP enabled interfaces lxcbr0 8000.fe0f8747d33f no veth3JU39Y現在看 lxc ...
mylxc 的 /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
如果不是,改好以後重開機..
ifconfig 看已經是 eth0 10.10.20.10 了,但是用 route -n 看..
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.10.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0沒有 default gateway...
手動設..
route add default gw 10.10.20.1 route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.10.20.1 0.0.0.0 UG 0 0 0 eth0 10.10.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0這時後 ping 10.10.20.1 已經OK
沒有留言:
張貼留言