LoginSignup
0

More than 5 years have passed since last update.

LXCの小メモ集

Last updated at Posted at 2018-06-29

sudo apt install lxc lxd-client lxd

LXDでubuntu 18.04のインスタンスを作る

lxc launch ubuntu:18.04 first

Bashにはいる

lxc exec first -- /bin/bash

ローカルへのアクセスを仮想インスタンスにポート転送で飛ばす

iptables -t nat -A PREROUTING -s 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to 10.25.35.199:80
iptables -t nat -A OUTPUT -s 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to 10.25.35.199:80

物理ネットワークカードと仮想マシンのポートを紐づけする

iptables -A PREROUTING -t nat -p tcp --dport 80 -i eth0 -j DNAT --to 10.25.35.199:80

別に、LXCのIPを明示すれば、そこに転送されるから、localhostはわざわざ転送しなくてもね?

Ref

https://help.ubuntu.com/lts/serverguide/lxc.html
https://linuxcontainers.org/ja/lxd/getting-started-cli/
https://homelab.city/ubuntu-18-04-lxd-zfs-docker-and-networking/
http://pc.amanogawa.info/archives/180
https://stackoverflow.com/questions/28170004/how-to-do-local-port-forwarding-with-iptables

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0