This file is indexed.

/etc/init/lxc-net.conf is in lxc 0.7.5-3ubuntu52.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
description "lxc network"
author "Serge Hallyn <serge.hallyn@canonical.com>"

start on starting lxc
stop on stopped lxc

env USE_LXC_BRIDGE="false"
env LXC_BRIDGE="lxcbr0"
env LXC_ADDR="10.0.3.1"
env LXC_NETMASK="255.255.255.0"
env LXC_NETWORK="10.0.3.0/24"
env LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
env LXC_DHCP_MAX="253"
env varrun="/var/run/lxc"

pre-start script
	[ -f /etc/default/lxc ] && . /etc/default/lxc

	[ "x$USE_LXC_BRIDGE" = "xtrue" ] || { stop; exit 0; }

	cleanup() {
		# dnsmasq failed to start, clean up the bridge
		iptables -t nat -D POSTROUTING -s ${LXC_NETWORK} -j MASQUERADE || true
		ifconfig ${LXC_BRIDGE} down || true
		brctl delbr ${LXC_BRIDGE} || true
	}

	if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
		if [ ! -f ${varrun}/network_up ]; then
			# bridge exists, but we didn't start it
			stop;
		fi
		exit 0;
	fi

	# set up the lxc network
	echo 1 > /proc/sys/net/ipv4/ip_forward
	mkdir -p ${varrun}
	brctl addbr ${LXC_BRIDGE}
	ifconfig ${LXC_BRIDGE} ${LXC_ADDR} netmask ${LXC_NETMASK} up
	iptables -A POSTROUTING -s ${LXC_NETWORK} -t nat -j MASQUERADE
	dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=${varrun}/dnsmasq.pid --conf-file= --listen-address ${LXC_ADDR} --dhcp-range ${LXC_DHCP_RANGE} --dhcp-lease-max=${LXC_DHCP_MAX} --dhcp-no-override --except-interface=lo --interface=${LXC_BRIDGE} || cleanup()
	touch ${varrun}/network_up
end script

post-stop script
	[ -f /etc/default/lxc ] && . /etc/default/lxc
	[ "x$USE_LXC_BRIDGE" = "xtrue" ] || exit 0;
	# if $LXC_BRIDGE has attached interfaces, don't shut it down
	ls /sys/class/net/${LXC_BRIDGE}/brif/* > /dev/null 2>&1 && exit 0;

	if [ -d /sys/class/net/${LXC_BRIDGE} ]; then
		ifconfig ${LXC_BRIDGE} down
		iptables -t nat -D POSTROUTING -s ${LXC_NETWORK} -j MASQUERADE || true
		pid=`cat ${varrun}/dnsmasq.pid 2>/dev/null` && kill -9 $pid || true
		rm -f ${varrun}/dnsmasq.pid
		brctl delbr ${LXC_BRIDGE}
	fi
	rm -f ${varrun}/network_up
end script