lxc-net should attempt to use ip before ifconfig, not vice-versa
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxc (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
The lxc-net script in /usr/lib/
As an example of why, lxc-net breaks the network setup within virtualbox guests. After starting lxc-net, the route table looks like:
ubuntu@
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 1024 0 0 eth0
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lxcbr0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
This is despite the following settings in /etc/default/
LXC_BRIDGE=
LXC_ADDR=
LXC_NETMASK=
LXC_NETWORK=
Switching the order in ifup and ifdown to try using ip first results in the correct netmask being applied:
ubuntu@
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 1024 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 lxcbr0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
Looking at sh -x output when running lxc-net manually, it *looks* like ifconfig is being invoked correctly, so I don't know why it's getting the netmask wrong:
+ use_iptables_
+ iptables -w -L -n
+ [ -d /sys/class/
+ brctl addbr lxcbr0
+ echo 1
+ [ ! -d /run/lxc ]
+ ifup lxcbr0 10.0.3.1 255.255.255.0
+ which ifconfig
+ [ 0 = 0 ]
+ ifconfig lxcbr0 10.0.3.1 netmask 255.255.255.0 up
+ return
ProblemType: Bug
DistroRelease: Ubuntu 15.04
Package: lxc 1.1.0-0ubuntu1
ProcVersionSign
Uname: Linux 3.18.0-13-generic i686
ApportVersion: 2.16.1-0ubuntu2
Architecture: i386
Date: Sat Feb 21 00:13:27 2015
InstallationDate: Installed on 2014-12-12 (70 days ago)
InstallationMedia: Ubuntu 15.04 "Vivid Vervet" - Alpha i386 (20141212)
ProcEnviron:
TERM=screen
SHELL=/bin/bash
PATH=(custom, no user)
LANG=en_US.UTF-8
XDG_RUNTIME_
SourcePackage: lxc
UpgradeStatus: No upgrade log present (probably fresh install)
defaults.conf:
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
modified.
mtime.conffile.
Changed in lxc (Ubuntu): | |
status: | Triaged → Fix Committed |
Changed in lxc (Ubuntu): | |
status: | Fix Committed → Fix Released |
Here's the complete sh -xe output from running lxc-net start:
ubuntu@ vivid-i386: ~$ sudo sh -xe /usr/lib/ i386-linux- gnu/lxc/ lxc-net start r=/etc/ default 255.255. 255.0 10.0.3. 0/24 RANGE=10. 0.3.2,10. 0.3.254 ubuntu- mirror. nxnw.org/ ubuntu BRIDGE= false lxc-net ] lxc-net 255.255. 255.0 10.0.3. 0/24 RANGE=10. 0.3.2,10. 0.3.254 TIMEOUT= 120 /var/lock/ subsys subsys/ lxc-net ] lock=-w net/lxcbr0 ] /run/lxc/ dnsmasq. pid --conf-file= --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp- lease-max= 253 --dhcp-no-override --except- interface= lo --interface=lxcbr0 --dhcp- leasefile= /var/lib/ misc/dnsmasq. lxcbr0. leases --dhcp- authoritative subsys/ lxc-net
+ distrosysconfdi
+ localstatedir=/var
+ varrun=/run/lxc
+ USE_LXC_BRIDGE=true
+ LXC_BRIDGE=lxcbr0
+ LXC_ADDR=10.0.3.1
+ LXC_NETMASK=
+ LXC_NETWORK=
+ LXC_DHCP_
+ LXC_DHCP_MAX=253
+ LXC_DHCP_CONFILE=
+ LXC_DOMAIN=
+ [ ! -f /etc/default/lxc ]
+ . /etc/default/lxc
+ MIRROR=http://
+ LXC_AUTO=true
+ USE_LXC_
+ [ -f /etc/default/
+ . /etc/default/
+ USE_LXC_BRIDGE=true
+ LXC_BRIDGE=lxcbr0
+ LXC_ADDR=10.0.3.1
+ LXC_NETMASK=
+ LXC_NETWORK=
+ LXC_DHCP_
+ LXC_DHCP_MAX=253
+ LXC_SHUTDOWN_
+ [ -d /var/lock/subsys ]
+ lockdir=
+ start
+ [ ! -f /var/lock/
+ [ xtrue = xtrue ]
+ use_iptables_
+ iptables -w -L -n
+ [ -d /sys/class/
+ brctl addbr lxcbr0
+ echo 1
+ [ ! -d /run/lxc ]
+ ifup lxcbr0 10.0.3.1 255.255.255.0
+ which ifconfig
+ [ 0 = 0 ]
+ ifconfig lxcbr0 10.0.3.1 netmask 255.255.255.0 up
+ return
+ iptables -w -I INPUT -i lxcbr0 -p udp --dport 67 -j ACCEPT
+ iptables -w -I INPUT -i lxcbr0 -p tcp --dport 67 -j ACCEPT
+ iptables -w -I INPUT -i lxcbr0 -p udp --dport 53 -j ACCEPT
+ iptables -w -I INPUT -i lxcbr0 -p tcp --dport 53 -j ACCEPT
+ iptables -w -I FORWARD -i lxcbr0 -j ACCEPT
+ iptables -w -I FORWARD -o lxcbr0 -j ACCEPT
+ iptables -w -t nat -A POSTROUTING -s 10.0.3.0/24 ! -d 10.0.3.0/24 -j MASQUERADE
+ iptables -w -t mangle -A POSTROUTING -o lxcbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
+ LXC_DOMAIN_ARG=
+ [ -n ]
+ getent passwd lxc-dnsmasq
+ break
+ dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=
+ touch /run/lxc/network_up
+ touch /var/lock/
+ exit 0