Difference between revisions of "LXC Ubuntu 16.04"
From MyWiki
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[ give an lxc container a static ip address ]]<br> | ||
+ | [[ Give an lxc container an external ip address ]]<br> | ||
+ | |||
+ | |||
https://tutorials.ubuntu.com/tutorial/tutorial-setting-up-lxd-1604#2<br> | https://tutorials.ubuntu.com/tutorial/tutorial-setting-up-lxd-1604#2<br> | ||
<source lang="text"> | <source lang="text"> | ||
Line 5: | Line 9: | ||
lxc image list ubuntu: | lxc image list ubuntu: | ||
https://www.youtube.com/watch?v=snWp-5K2LO4 | https://www.youtube.com/watch?v=snWp-5K2LO4 | ||
+ | lxc exec first -- /bin/bash | ||
+ | iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to [DestinationIP:PORT] | ||
+ | iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 587 -j DNAT --to-destination 10.0.3.100:587 | ||
+ | To set static ip addresses - https://medium.com/@ali_oguzhan/lxd-assigning-static-ip-to-containers-ecf558982071 | ||
+ | autostarting containers - https://www.cyberciti.biz/faq/how-to-auto-start-lxd-containers-at-boot-time-in-linux/ | ||
+ | lxc launch images:centos/7 centos | ||
+ | </source> | ||
+ | |||
+ | Give static ip address to containers in modern version of lxd | ||
+ | <source lang="text"> | ||
+ | |||
+ | lxc stop c1 | ||
+ | lxc network attach lxdbr0 c1 eth0 eth0 | ||
+ | lxc config device set c1 eth0 ipv4.address 10.99.10.42 | ||
+ | lxc start c1 | ||
+ | |||
</source> | </source> |
Latest revision as of 09:31, 7 August 2021
give an lxc container a static ip address
Give an lxc container an external ip address
https://tutorials.ubuntu.com/tutorial/tutorial-setting-up-lxd-1604#2
There are two repositories - images repository and ubuntu repository lxc image list images: lxc image list ubuntu: https://www.youtube.com/watch?v=snWp-5K2LO4 lxc exec first -- /bin/bash iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to [DestinationIP:PORT] iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 587 -j DNAT --to-destination 10.0.3.100:587 To set static ip addresses - https://medium.com/@ali_oguzhan/lxd-assigning-static-ip-to-containers-ecf558982071 autostarting containers - https://www.cyberciti.biz/faq/how-to-auto-start-lxd-containers-at-boot-time-in-linux/ lxc launch images:centos/7 centos
Give static ip address to containers in modern version of lxd
lxc stop c1 lxc network attach lxdbr0 c1 eth0 eth0 lxc config device set c1 eth0 ipv4.address 10.99.10.42 lxc start c1