Skip to content

Instantly share code, notes, and snippets.

@ysaotome
Last active August 14, 2017 20:20
Show Gist options
  • Save ysaotome/a2e18e98bf3c5cd60a73 to your computer and use it in GitHub Desktop.
Save ysaotome/a2e18e98bf3c5cd60a73 to your computer and use it in GitHub Desktop.
LXC環境セットアップ時のメモ
LXC環境セットアップ時のメモ
Ubuntu 14.04ホストセットアップ
下記を設定
https://gist.github.com/ysaotome/cdc02c05425e01abc500
LXCセットアップ
http://www.server-world.info/query?os=Ubuntu_14.04&p=lxc&f=1
sudo apt install lxc
LXC Web Panelセットアップ
sudo apt install python-dev
sudo sh -c "wget http://lxc-webpanel.github.io/tools/install.sh -O - | bash"
sudo vi /srv/lwp/lwp.conf
debug = true
NAT設定
https://gist.github.com/kimus/9315140
http://qiita.com/tukiyo3/items/56525cb1b30cdd19fade
sudo vi /etc/ufw/sysctl.conf
net.ipv4.ip_forward=1
#net/ipv6/conf/default/forwarding=1
#net/ipv6/conf/all/forwarding=1
sudo sysctl -p
sudo vim /etc/default/ufw
IPV6=no
DEFAULT_FORWARD_POLICY="ACCEPT"
sudo vi /etc/ufw/before.rules
# NAT table rules
*nat
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
# Port Forwardings
-A PREROUTING -i eth0 -p tcp -m tcp --dport 22222 -j DNAT --to-destination 10.0.3.10:22
-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.3.20:80
-A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.3.20:443
# Forward traffic through eth0 - Change to match you out-interface
-A POSTROUTING -s 10.0.3.0/24 ! -d 10.0.3.0/24 -j MASQUERADE
# don't delete the 'COMMIT' line or these nat table rules won't
# be processed
COMMIT
sudo ufw reload
sudo ufw status verbose
テンプレートのデフォルトのアクセス先を修正
http://isid.ai/dev/2013/08/02/736/
sudo vi /usr/share/lxc/templates/lxc-ubuntu
case $2 in
amd64|i386)
MIRROR=${MIRROR:-http://ftp.riken.go.jp/Linux/ubuntu}
SECURITY_MIRROR=${SECURITY_MIRROR:-http://ftp.riken.go.jp/Linux/ubuntu}
;;
デフォルトイメージを作成する
sudo lxc-create -n Ubuntu1404x8664 -t ubuntu
sudo lxc-console -n Ubuntu1404x8664
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment