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