You are using LXD containers and you want a container (or more) to use an IP address from the LAN (or, get an IP address just like the host does).
LXD 컨테이너를 사용하고 있으며 LAN에서 IP 주소를 사용하도록 컨테이너(또는 여러 개)를 설정하거나 호스트와 동일한 방식으로 IP 주소를 얻고 싶습니다.
LXD currently supports four ways to do that, and depending on your needs, you select the appropriate way.
LXD는 현재 이를 수행하는 네 가지 방법을 지원하며, 필요에 따라 적절한 방법을 선택합니다.
- Using
macvlan
. See https://blog.simos.info/how-to-make-your-lxd-container-get-ip-addresses-from-your-lan/ - Using
bridged
. See https://blog.simos.info/how-to-make-your-lxd-containers-get-ip-addresses-from-your-lan-using-a-bridge/
bridged
. https://blog.simos.info/how-to-make-your-lxd-containers-get-ip-addresses-from-your-lan-using-a-bridge/ - Using
routed
. See https://blog.simos.info/how-to-get-lxd-containers-get-ip-from-the-lan-with-routed-network/
routed
. https://blog.simos.info/how-to-get-lxd-containers-get-ip-from-the-lan-with-routed-network/ - Using
ipvlan
. It is this tutorial, you are reading it now.
ipvlan
. 당신이 지금 읽고 있는 이 튜토리얼입니다.
Why use the ipvlan
networking?
왜 ipvlan
네트워킹을 사용하나요?
You would use the ipvlan
networking if you want to expose containers to the local network (LAN, or the Internet if you are using an Internet server, and have allocated several public IPs).
로컬 네트워크(LAN) 또는 인터넷 서버를 사용하고 여러 개의 공인 IP를 할당한 경우 ipvlan
네트워킹을 사용하여 컨테이너를 노출할 수 있습니다.
Any containers with ipvlan
will appear on the network to have the MAC address of the host. Therefore, this will work even when you use it on your laptop that is connected to the network over WiFi (or any router with port security). That is, you can use ipvlan
when macvlan
and bridged
cannot work.
네트워크에 ipvlan
가 있는 모든 컨테이너는 호스트의 MAC 주소를 가진 것처럼 나타납니다. 따라서 WiFi(또는 포트 보안이 있는 라우터)에 연결된 노트북에서 사용하더라도 작동합니다. 즉, macvlan
와 bridged
가 작동하지 않을 때 ipvlan
을 사용할 수 있습니다.
You have to use static network configuration for these containers. Which means,
이 컨테이너에 대해 정적 네트워크 구성을 사용해야 합니다. 즉,
- You need to make sure that the IP address on the network that you give to the
ipvlan
container, will not be assigned by the router in the future. Otherwise, there will be an IP conflict. You can do so if you go into the configuration of the router, and specify that the IP address is in use.
네트워크에서ipvlan
컨테이너에 제공하는 IP 주소가 향후 라우터에 의해 할당되지 않도록 해야 합니다. 그렇지 않으면 IP 충돌이 발생할 수 있습니다. 라우터의 설정에 들어가서 IP 주소가 사용 중임을 지정하면 그렇게 할 수 있습니다. - The container (i.e. the services running in the container) should not be performing changes to the network interface.
컨테이너(즉, 컨테이너에서 실행 중인 서비스)는 네트워크 인터페이스에 대한 변경을 수행해서는 안 됩니다.
If you use some special Linux distribution, you can verify whether your LXD installation supports ipvlan
by running the following command:
특별한 리눅스 배포판을 사용하는 경우, 다음 명령어를 실행하여 LXD 설치가 ipvlan
를 지원하는지 확인할 수 있습니다:
$ lxc info
...
api_extensions:
...
- container_nic_ipvlan
- container_nic_ipvlan_gateway
- container_nic_ipvlan_host_table
- container_nic_ipvlan_mode
...
lxc_features:
network_ipvlan: "true"
...
$
Special requirements for container images
컨테이너 이미지에 대한 특별 요구 사항
The default network configuration in Ubuntu 18.04 or newer is to use netplan
and get eth0
to use DHCP for the configuration. The way netplan
does this, messes up with ipvlan
, so we are using a workaround. Depending on the Linux distribution in the container, you may need special configuration. The Ubuntu workaround is based on cloud-init
, so it is the whole section for cloud-init
in the profile below. Below is the list of LXD profiles per Linux distribution in the container image.
Ubuntu 18.04 이상에서 기본 네트워크 구성은 netplan
를 사용하고 eth0
을 사용하여 DHCP로 구성을 받는 것입니다. netplan
가 이를 수행하는 방식은 ipvlan
에 문제를 일으키므로 우리는 우회 방법을 사용하고 있습니다. 컨테이너의 리눅스 배포판에 따라 특별한 구성이 필요할 수 있습니다. 우분투 우회 방법은 cloud-init
를 기반으로 하므로 아래 프로필의 cloud-init
에 대한 전체 섹션입니다. 아래는 컨테이너 이미지의 리눅스 배포판별 LXD 프로필 목록입니다.
- Ubuntu container images 우분투 컨테이너 이미지
- CentOS container images CentOS 컨테이너 이미지
- Debian container images Debian 컨테이너 이미지
ipvlan
LXD profile for Ubuntu container images
ipvlan
우분투 컨테이너 이미지용 LXD 프로필
Here is the ipvlan
profile, which has been tested on Ubuntu. Create a profile with this name. Then, for each container that uses the ipvlan
network, we will be creating a new individual profile based on this initial profile. The reason why we create such individual profiles, is that we need to hard-code the IP address in them. Below, in bold, you can see the values that changes, specifically, the IP address (in two locations, replace with your own public IP addresses), the parent interface (on the host), and the nameserver IP address (that one is a public DNS server from Google). You can create an empty profile, then edit it and replace the existing content with the following (lxc profile create ipvlan
, lxc profile edit ipvlan
).
여기 ipvlan
프로필이 있습니다. 이 프로필은 Ubuntu에서 테스트되었습니다. 이 이름으로 프로필을 생성하세요. 그런 다음 ipvlan
네트워크를 사용하는 각 컨테이너에 대해 이 초기 프로필을 기반으로 새로운 개별 프로필을 생성할 것입니다. 개별 프로필을 생성하는 이유는 IP 주소를 하드코딩해야 하기 때문입니다. 아래에서 볼 수 있듯이, 변경되는 값은 굵게 표시되어 있으며, 특히 IP 주소(두 위치에서, 자신의 공인 IP 주소로 교체), 부모 인터페이스(호스트에서) 및 네임서버 IP 주소(구글의 공용 DNS 서버)입니다. 빈 프로필을 생성한 후, 이를 편집하고 기존 내용을 다음으로 교체할 수 있습니다 ( lxc profile create ipvlan
, lxc profile edit ipvlan
).
config:
user.network-config: |
#cloud-config
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.200/32
dhcp4: no
dhcp6: no
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
routes:
- to: 0.0.0.0/0
via: 169.254.0.1
on-link: true
description: "ipvlan LXD profile"
devices:
eth0:
ipv4.address: 192.168.1.200
nictype: ipvlan
parent: enp3s0
type: nic
name: ipvlan
used_by:
We are going to make copies of the ipvlan
profile to individual new ones, one for each IP address. Therefore, let’s create the LXD profiles for 192.168.1.200
and 192.168.1.201
. When you edit them
우리는 ipvlan
프로필의 복사본을 각 IP 주소마다 하나씩 개별 새 프로필로 만들 것입니다. 따라서 192.168.1.200
및 192.168.1.201
에 대한 LXD 프로필을 생성합시다. 편집할 때
$ lxc profile copy ipvlan ipvlan_192.168.1.200
$ EDITOR=nano lxc profile edit ipvlan_192.168.1.200
$ lxc profile copy ipvlan ipvlan_192.168.1.201
$ EDITOR=nano lxc profile edit ipvlan_192.168.1.201
Skip to the next main section to test the profile.
프로필을 테스트하기 위해 다음 주요 섹션으로 건너뛰세요.
ipvlan
LXD profile for Debian container images
ipvlan
Debian 컨테이너 이미지용 LXD 프로필
The following is an alternative LXD ipvaln
profile that can be used on Debian 10 (buster
). It might be useful for other Linux distributions as well. If this specific LXD profile works for a distribution other than Debian, please report it below so that I can update the post. It explicitly makes the container not to set network configuration through DHCP. It further uses cloud-init
instructions to manually create a /etc/resolv.conf
because without DHCP there wouldn’t be such a file in the container. The suggested DNS server is 8.8.8.8 (Google), and you may change if you would like. In bold, you can see the two items that you need to update for your case; the IP address for the container, and the network interface of the host that this container will attach to (through ipvlan
). Note that without the dhcp4: false
instruction in the following, the container will take a minute or two until it completes the startup. That is, the container tries to get a DHCP lease until it times out, and then cloud-init
will eventually setup the nameserver.
다음은 Debian 10 ( buster
)에서 사용할 수 있는 대체 LXD ipvaln
프로필입니다. 다른 Linux 배포판에도 유용할 수 있습니다. 이 특정 LXD 프로필이 Debian 이외의 배포판에서 작동한다면, 아래에 보고해 주시면 게시물을 업데이트할 수 있습니다. 이 프로필은 컨테이너가 DHCP를 통해 네트워크 구성을 설정하지 않도록 명시적으로 설정합니다. 또한 cloud-init
지침을 사용하여 수동으로 /etc/resolv.conf
을 생성합니다. DHCP가 없으면 컨테이너에 그러한 파일이 없기 때문입니다. 제안된 DNS 서버는 8.8.8.8 (Google)이며, 원하시면 변경할 수 있습니다. 굵게 표시된 두 항목은 귀하의 경우에 맞게 업데이트해야 하는 항목입니다. 컨테이너의 IP 주소와 이 컨테이너가 연결될 호스트의 네트워크 인터페이스입니다 ( ipvlan
를 통해). 다음의 dhcp4: false
지침이 없으면 컨테이너가 시작을 완료하는 데 1분 또는 2분이 걸립니다. 즉, 컨테이너는 DHCP 임대를 받으려고 시도하다가 시간이 초과되면 cloud-init
가 결국 nameserver를 설정합니다.
config:
user.network-config: |
#cloud-config
version: 2
ethernets:
eth0:
dhcp4: false
dhcp6: false
user.user-data: |
#cloud-config
bootcmd:
- echo 'nameserver 8.8.8.8' > /etc/resolvconf/resolv.conf.d/tail
- systemctl restart resolvconf
description: ipvlan profile for Debian container images
devices:
eth0:
ipv4.address: 192.168.1.201
name: eth0
nictype: ipvlan
parent: enp3s0
type: nic
name: ipvlan_debian
You can launch such a Debian container with ipvlan
using a command line like the following.
다음과 같은 명령어를 사용하여 ipvlan
로 이러한 Debian 컨테이너를 시작할 수 있습니다.
lxc launch images:debian/10/cloud mydebian --profile default --profile ipvlan_debian
Note that for Debian 11 (currently not released yet) the above does not work. If you can figure out a way to make it work for Debian 11, please write a comment.
Debian 11(현재 아직 출시되지 않음)에서는 위의 방법이 작동하지 않습니다. Debian 11에서 작동하도록 만드는 방법을 찾을 수 있다면 댓글을 남겨주세요.
ipvlan
LXD profile for Fedora container images
ipvlan
페도라 컨테이너 이미지용 LXD 프로필
The following is an alternative LXD routed
profile that can be used on Fedora. It might be useful for other Linux distributions as well. If this specific LXD profile works for a distribution other than Fedora, please report it below so that I can update the post. The profile has two sections; the cloud-init
section that configures once the networking in the container using NetworkManager, and the LXD network configuration that directs LXD on how to setup the routed
networking on the host. The suggested DNS server is 8.8.8.8 (Google), and you may change if you would like with other free public DNS servers. In bold, you can see the two items that you need to update for your case; the IP address for the container, and the network interface of the host that this container will attach to (through ipvlan
).
다음은 페도라에서 사용할 수 있는 대체 LXD routed
프로필입니다. 다른 리눅스 배포판에도 유용할 수 있습니다. 이 특정 LXD 프로필이 페도라 이외의 배포판에서 작동한다면, 아래에 보고해 주시면 게시물을 업데이트할 수 있습니다. 이 프로필은 두 개의 섹션으로 구성되어 있습니다. 첫 번째는 NetworkManager를 사용하여 컨테이너 내에서 네트워킹을 구성하는 cloud-init
섹션이며, 두 번째는 LXD가 호스트에서 routed
네트워킹을 설정하는 방법을 지시하는 LXD 네트워크 구성입니다. 제안된 DNS 서버는 8.8.8.8(구글)이며, 다른 무료 공용 DNS 서버로 변경할 수 있습니다. 굵게 표시된 두 항목은 귀하의 경우에 맞게 업데이트해야 하는 항목입니다. 컨테이너의 IP 주소와 이 컨테이너가 연결될 호스트의 네트워크 인터페이스( ipvlan
를 통해)입니다.
Note that you would launch the container with a command line
컨테이너를 명령줄로 실행할 것임을 유의하세요
lxc launch images:fedora/33/cloud myfedora --profile default --profile ipvlan_fedora
config:
user.user-data: |
#cloud-config
bootcmd:
- nmcli connection modify "System eth0" ipv4.addresses 192.168.1.202/32
- nmcli connection modify "System eth0" ipv4.gateway 169.254.0.1
- nmcli connection modify "System eth0" ipv4.dns 8.8.8.8
- nmcli connection modify "System eth0" ipv4.method manual
- nmcli connection down "System eth0"
- nmcli connection up "System eth0"
description: Default LXD profile
devices:
eth0:
ipv4.address: 192.168.1.202
name: eth0
nictype: routed
parent: enp3s0
type: nic
name: ipvlan_fedora
Using the ipvlan
networking in LXD
LXD에서 ipvlan
네트워킹 사용하기
We create a container called myipvlan using the default
profile and on top of that the ipvlan
profile.
우리는 default
프로필을 사용하여 myipvlan이라는 컨테이너를 만들고 그 위에 ipvlan
프로필을 추가합니다.
$ lxc launch ubuntu:20.04 myipvlan --profile default --profile ipvlan
Creating myipvlan
Starting myipvlan
$ lxc list myipvlan
+----------+---------+----------------------+-----------+-----------+
| NAME | STATE | IPV4 | TYPE | SNAPSHOTS |
+----------+---------+----------------------+-----------+-----------+
| myipvlan | RUNNING | 192.168.1.200 (eth0) | CONTAINER | 0 |
+----------+---------+----------------------+-----------+-----------+
$
According to LXD, the container has configured its IP address that was packaged into the cloud-init configuration.
LXD에 따르면, 컨테이너는 클라우드 초기화 구성에 패키지된 IP 주소를 구성했습니다.
Get a shell into the container and ping
컨테이너에 셸을 열고 핑을 보내세요
- other IP addresses on your LAN
귀하의 LAN에 있는 다른 IP 주소들 - an Internet host such as
www.google.com
.
www.google.com
와 같은 인터넷 호스트.
Here is a test try using a Fedora container image.
여기 페도라 컨테이너 이미지를 사용한 테스트 시도가 있습니다.
$ lxc launch images:fedora/33/cloud myfedora --profile default --profile ipvlan_fedora
Creating myfedora
Starting myfedora
$ lxc list myfedora
+----------+---------+----------------------+-----------+-----------+
| NAME | STATE | IPV4 | TYPE | SNAPSHOTS |
+----------+---------+----------------------+-----------+-----------+
| myfedora | RUNNING | 192.168.1.202 (eth0) | CONTAINER | 0 |
+----------+---------+----------------------+-----------+-----------+
$ lxc shell myfedora
[root@myfedora ~]# ping -c 3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=111 time=12.1 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=111 time=12.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=111 time=12.1 ms
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 12.148/110.215/201.306/117.007 ms
[root@myfedora ~]# logout
$
Conclusion 결론
We have seen how to setup and use ipvlan
in LXD, when launching Ubuntu and Fedora container images (Debian is still pending, if you figure it out, please write a comment).
우리는 Ubuntu와 Fedora 컨테이너 이미지를 실행할 때 LXD에서 ipvlan
를 설정하고 사용하는 방법을 보았습니다(데비안은 아직 대기 중이며, 해결하신 경우 댓글을 남겨주세요).
We show how to use LXD profiles to setup easily the creation of the container, and in the profile we add the IP address of the container. This means that for each container we would need to create individual LXD profiles. Note that a LXD profile is attached to a container, so if you want to change it for another container, the change will apply to any existing container as well (i.e. mess). You also could create the containers without needing an additional LXD profile, by perform lxc config
commands on the host, and networking commands inside the container. We do not show that here.
LXD 프로필을 사용하여 컨테이너 생성을 쉽게 설정하는 방법을 보여주며, 프로필에 컨테이너의 IP 주소를 추가합니다. 이는 각 컨테이너마다 개별 LXD 프로필을 생성해야 함을 의미합니다. LXD 프로필은 컨테이너에 연결되어 있으므로, 다른 컨테이너에 대해 변경하려면 변경 사항이 기존의 모든 컨테이너에도 적용됩니다(즉, 혼란). 또한 호스트에서 lxc config
명령을 수행하고 컨테이너 내부에서 네트워킹 명령을 실행하여 추가 LXD 프로필 없이 컨테이너를 생성할 수도 있습니다. 여기서는 그 방법을 보여주지 않습니다.
You get a similar result when using ipvlan
and routed
. I do not go into detail about the practical differences between the two.
ipvlan
와 routed
을 사용할 때 유사한 결과를 얻습니다. 두 가지의 실제적인 차이에 대해서는 자세히 설명하지 않겠습니다.
Luken 2021년 2월 27일 12:00
What exactly doesn’t work with Debian? If we knew it would be easier to help.
Debian에서 정확히 무엇이 작동하지 않나요? 우리가 알았다면 도와주기 더 쉬웠을 것입니다.
Simos Xenitellis 2021년 2월 27일 20:28
Author 저자
Thanks for the reply.
답변해 주셔서 감사합니다.
If you run the commands for Debian, you will notice that the networking in the container is not setup correctly. The container does not have network connectivity. This is likely related to the Debian runtime that apparently resets some network configuration that is provided by LXD.
Debian 명령어를 실행하면 컨테이너의 네트워킹이 올바르게 설정되지 않았음을 알 수 있습니다. 컨테이너는 네트워크 연결이 없습니다. 이는 LXD에서 제공하는 일부 네트워크 구성을 재설정하는 것으로 보이는 Debian 런타임과 관련이 있을 가능성이 높습니다.
I tested Debian 10 image and networking works just fine. I used
debian/buster/cloud
image, and two profiles:나는 Debian 10 이미지를 테스트했으며 네트워킹이 잘 작동합니다. 나는
debian/buster/cloud
이미지를 사용했고 두 개의 프로필을 사용했습니다:debian-test:
I didn’t notice any issues with networking.
네트워킹에 문제를 발견하지 못했습니다.
Simos Xenitellis 2021년 3월 1일 21:16
Author 저자
Thanks Łukasz! 감사합니다, Łukasz!
I just realized that Debian 11 is still in development and Debian 10 is the latest version.
나는 방금 데비안 11이 아직 개발 중이고 데비안 10이 최신 버전이라는 것을 깨달았다.
I updated the LXD profile for Debian 10 and now it works with
ipvlan
.나는 Debian 10의 LXD 프로필을 업데이트했으며 이제
ipvlan
와 함께 작동합니다.Compared to your version, I just added the
dhcp4: false
in the profile so that the container is usable as soon as it is started.귀하의 버전과 비교하여, 저는 프로필에
dhcp4: false
를 추가하여 컨테이너가 시작되자마자 사용 가능하도록 했습니다.Because if DHCP is not disabled in the container, the container tries to get a DHCP lease, it takes about a minute to time out.
컨테이너에서 DHCP가 비활성화되지 않으면 컨테이너가 DHCP 임대를 받으려고 시도하며, 타임아웃까지 약 1분이 걸립니다.
And only then it runs the
bootcmd
instruction to setup the nameserver.그리고 그때만
bootcmd
명령을 실행하여 네임서버를 설정합니다.Łukasz Zaroda 2021년 3월 1일 20:26
I tested also Debian 11 image, and it also kind of works. Kind of, because there was one difference: DNS resolution didn’t work. It turns out that /etc/resolv.conf is not being updated with
systemctl restart resolvconf
for some reason, so I had to manually putnameserver 8.8.8.8
there, and name resolution started working.나는 또한 Debian 11 이미지를 테스트했으며, 그것도 어느 정도 작동합니다. 어느 정도 작동하는 이유는 하나의 차이가 있었기 때문입니다: DNS 해상도가 작동하지 않았습니다. 어떤 이유에서인지 /etc/resolv.conf가
systemctl restart resolvconf
로 업데이트되지 않아서, 수동으로nameserver 8.8.8.8
을 거기에 넣어야 했고, 이름 해상도가 작동하기 시작했습니다.Simos Xenitellis 2021년 3월 1일 21:20
Author 저자
I think that was the issue when I was testing with Debian 11.
나는 Debian 11로 테스트할 때 그것이 문제였다고 생각한다.
The changes in the networking in Debian 11 makes is to that any external configuration of the nameserver
Debian 11의 네트워킹 변화로 인해 이름 서버의 외부 구성이 가능해졌습니다
is reset as soon as the container starts up.
컨테이너가 시작되면 즉시 재설정됩니다.
The requirements are 요구 사항은
컨테이너는 시작하자마자 사용할 수 있어야 합니다(네트워킹이 제대로 설정되어 있어야 하며, 이름 서버를 포함합니다).
컨테이너를 다시 시작하면 여전히 작동해야 합니다.
Maybe this
user.network-config
part broke the networking, but it doesn’t seem to be required.아마 이
user.network-config
부분이 네트워킹을 망가뜨렸지만, 필요하지 않은 것 같습니다.Simos Xenitellis 2021년 3월 3일 19:52
Author 저자
If there is no
user.network-config
, then it works for Debian 11?user.network-config
가 없다면, Debian 11에서 작동합니까?If you have a working profile for Debian 11, I am happy to add above.
Debian 11에 대한 작동 프로필이 있다면, 기꺼이 위에 추가하겠습니다.
Andrew 2021년 3월 3일 15:10
Hi, please help! I have CentOS 8 container running with ipvlan device config. Everything works fine but there is an issue with set nameservers. Problem is that i can’t ping google.com but i can ping 8.8.8.8
안녕하세요, 도와주세요! 저는 ipvlan 장치 구성이 있는 CentOS 8 컨테이너를 실행하고 있습니다. 모든 것이 잘 작동하지만 네임서버 설정에 문제가 있습니다. 문제는 google.com에 핑을 보낼 수 없지만 8.8.8.8에는 핑을 보낼 수 있다는 것입니다.
I try use “fedora” approach but there no luck for me.
나는 "페도라" 접근 방식을 사용해 보지만 나에게는 운이 없다.
/etc/resolv.conf don’t change
/etc/resolv.conf 변경하지 마세요
Thanks! 감사합니다!
Simos Xenitellis 2021년 3월 3일 19:58
Author 저자
Most likely Centos 8 (Stream or non-stream?) has small but significant differences to Fedora.
가장 가능성이 높은 Centos 8 (스트림 또는 비스트림?)은 페도라와 작지만 중요한 차이가 있습니다.
What is happening is that NetworkManager in Centos 8 has a final say in the end, and configures a nameserver (overwriting our setting).
Centos 8의 NetworkManager가 결국 최종 결정을 내리고, 우리의 설정을 덮어쓰며 네임서버를 구성하고 있습니다.
That nameserver is the host which likely does not respond due to
ipvlan
.그 네임서버는
ipvlan
때문에 응답하지 않을 가능성이 있는 호스트입니다.What you need is to get the container not to set a DNS server and have it set one yourself.
당신이 필요한 것은 컨테이너가 DNS 서버를 설정하지 않도록 하고, 대신 당신이 직접 설정하는 것입니다.
What’s your container image (
images:centos/8/cloud
?)?당신의 컨테이너 이미지 (
images:centos/8/cloud
?)는 무엇인가요?Thanks for your reply. My container image is images:centos/8 not cloud and not stream. I put nameserver 8.8.8.8 to /etc/resolv.conf by hand and with that ping to google.com work fine. However, I don’t think it’s right to manually add nameserver
답변해 주셔서 감사합니다. 제 컨테이너 이미지 는 images:centos/8 이고 cloud도 stream도 아닙니다. 저는 nameserver 8.8.8.8 을 /etc/resolv.conf 에 수동으로 추가했으며, 그 덕분에 google.com 에 핑이 잘 됩니다. 그러나 nameserver 를 수동으로 추가하는 것이 옳다고 생각하지 않습니다.
Simos Xenitellis 2021년 3월 4일 08:32
Author 저자
The
images:centos/8
container image does not have support forcloud-init
. This means that it is not possible to automate the creation of such a container with ipvlan, using just a LXD profile.images:centos/8
컨테이너 이미지에는cloud-init
에 대한 지원이 없습니다. 이는 LXD 프로필만 사용하여 ipvlan으로 이러한 컨테이너의 생성을 자동화할 수 없음을 의미합니다.In that
ipvlan
LXD profile we have added instructions for both LXD and the container to setup themselves and enableipvlan
networking. The instructions for the container are written incloud-init
instructions (upper part), and the container has to supportcloud-init
in order to parse them and execute them. The alternative is to type these commands destined for the container as soon as you get a shell into the container, manually.해당
ipvlan
LXD 프로필에서는 LXD와 컨테이너가 스스로 설정하고ipvlan
네트워킹을 활성화할 수 있도록 지침을 추가했습니다. 컨테이너에 대한 지침은cloud-init
지침(상단 부분)에 작성되어 있으며, 컨테이너는 이를 구문 분석하고 실행하기 위해cloud-init
을 지원해야 합니다. 대안은 컨테이너에 대한 이러한 명령을 수동으로 입력하는 것입니다.Note that in some container images, the default networking subsystem will reset some networking parameters, which will make the container lose the networking configuration that LXD applied in the very beginning. With cloud-init, we can instruct the container image not to do that.
일부 컨테이너 이미지에서는 기본 네트워킹 서브시스템이 일부 네트워킹 매개변수를 재설정하여 컨테이너가 LXD가 처음에 적용한 네트워킹 구성을 잃게 됩니다. cloud-init를 사용하면 컨테이너 이미지가 그렇게 하지 않도록 지시할 수 있습니다.
Andrew 2021년 3월 4일 09:06
Thanks a lot for the clarification. In my next container I will try images:centos/8/cloud. For now hardcoded resolv.conf suits me for current needs. Thanks!
명확한 설명 감사합니다. 다음 컨테이너에서는 images:centos/8/cloud를 시도해 보겠습니다. 현재로서는 하드코딩된 resolv.conf가 현재 필요에 적합합니다. 감사합니다!
Worked to ping / inet connection from within container, but no ping into the container from within the LAN… any clues?
컨테이너 내에서 핑/인터넷 연결을 시도했지만 LAN 내에서 컨테이너로 핑이 안 됩니다… 어떤 단서가 있을까요?
Simos Xenitellis 2021년 4월 13일 23:06
Author 저자
Hi! 안녕하세요!
You should be able to ping from another computer on the LAN to the IP address of the ipvlan LXD container.
다른 컴퓨터에서 LAN을 통해 ipvlan LXD 컨테이너의 IP 주소로 핑을 보낼 수 있어야 합니다.
Verify first that you can ping the LXD host from the other computers on the LAN.
먼저 LAN의 다른 컴퓨터에서 LXD 호스트에 핑을 보낼 수 있는지 확인하십시오.
Use
tcpdump
, first on the host, then in the ipvlan LXD container to follow the ICMP packets.tcpdump
를 사용하여 호스트에서 먼저, 그런 다음 ipvlan LXD 컨테이너에서 ICMP 패킷을 추적합니다.I
ping
-ed from my phone to the ipvlan LXD container. Here is the output oftcpdump
on the host:And here is the output of
tcpdump
in the ipvlan LXD container,Sergey 2021년 5월 5일 11:42
Thank you very much for such helpful articles!
이렇게 유용한 기사에 대해 정말 감사합니다!
I managed to set up an ipvlan network, but one problem remained:
ipvlan 네트워크를 설정하는 데 성공했지만, 한 가지 문제가 남아 있었습니다:
I cannot access (ssh, ftp, http, ..?) To the container from another computer on the same local network, but ping works.
나는 같은 로컬 네트워크에 있는 다른 컴퓨터에서 컨테이너에 접근할 수 없지만(ping은 작동함) (ssh, ftp, http, ..?)
It turned out that this issue can be solved by disabling UFW on the host with LXD. However, I would like it to be enabled.
이 문제는 LXD가 있는 호스트에서 UFW를 비활성화함으로써 해결할 수 있는 것으로 나타났습니다. 그러나 저는 그것이 활성화되기를 원합니다.
Is it possible to somehow configure it for the container in the same way as for the host itself?
컨테이너를 호스트 자체와 같은 방식으로 구성하는 것이 가능합니까?
For example, I want only port 22 to be accessible on the container from my local network.
예를 들어, 로컬 네트워크에서 컨테이너에 접근할 수 있는 포트는 22만 원합니다.
Simos Xenitellis 2021년 5월 6일 10:24
Author 저자
Thank you! 감사합니다!
You are describing a common issue with firewalls and their interactions with network services on a host.
방화벽과 호스트의 네트워크 서비스 간의 상호작용에 대한 일반적인 문제를 설명하고 있습니다.
That is, these two are different and independent, and in a way that is the way it should be.
즉, 이 두 가지는 다르고 독립적이며, 그런 방식이 마땅한 방식이다.
Potentially, LXD could be able to open some firewall rules when you launch an
ipvlan
container.잠재적으로, LXD는
ipvlan
컨테이너를 실행할 때 일부 방화벽 규칙을 열 수 있을 것입니다.It is not unprecedented. When you create a proxy device with the
nat=true
flag, LXD creates firewall rules for you전례가 없는 것은 아닙니다.
nat=true
플래그로 프록시 장치를 생성하면 LXD가 방화벽 규칙을 생성합니다.for the port forwarding. It is so cool that these rules are attached to the container.
포트 포워딩을 위해. 이러한 규칙이 컨테이너에 연결되어 있다는 것이 정말 멋지다.
The container is gone? The rules are gone as well, without further interaction from you.
컨테이너가 사라졌나요? 규칙도 사라졌습니다, 당신의 추가적인 상호작용 없이.
You can ask for such a feature at https://github.com/lxc/lxd/issues
https://github.com/lxc/lxd/issues에서 이러한 기능을 요청할 수 있습니다.
In any case, LXD sets up the IP address for you with the ipvlan,
어쨌든 LXD는 ipvlan으로 IP 주소를 설정합니다
and is something that is not completely out of the question.
그리고 이는 전혀 불가능한 것은 아닙니다.
Sergey 2021년 5월 6일 11:35
What you are describing sounds very interesting and really convenient, but I’m not sure if I understood you correctly.
당신이 설명하는 것은 매우 흥미롭고 정말 편리하게 들리지만, 제가 당신을 제대로 이해했는지 확신이 서지 않습니다.
Let me ask you a clarifying question: let’s say that my host computer has IP 192.168.1.100 and the container running on it has IP 192.168.1.200 via ipvlan. If I understood correctly (or just heard what I wanted to hear, not the truth), by adding a properly configured proxy device to this container, I can open access to 192.168.1.200:22 (tcp) for computers on the same local network when UFW is enabled is enabled?
명확한 질문을 드리겠습니다: 제 호스트 컴퓨터의 IP가 192.168.1.100이고 그 위에서 실행 중인 컨테이너의 IP가 ipvlan을 통해 192.168.1.200이라고 가정해 보겠습니다. 제가 제대로 이해했다면 (아니면 제가 듣고 싶은 것만 들었거나 진실이 아닐 수도 있지만), 이 컨테이너에 적절하게 구성된 프록시 장치를 추가함으로써 UFW가 활성화된 상태에서 같은 로컬 네트워크에 있는 컴퓨터들이 192.168.1.200:22 (tcp)에 접근할 수 있게 할 수 있습니까?
Or is it about proxying some other (free) port, for example 2222 (to port 22 of the container)?
아니면 다른 (무료) 포트, 예를 들어 2222를 (컨테이너의 포트 22로) 프록시하는 것에 관한 건가요?
I did a similar trick earlier, whith the host IP.
나는 이전에 호스트 IP로 비슷한 트릭을 했습니다.
I tried adding proxy devices to proxy container port 22 to host port 22, but got an “address already in use” error.
프록시 컨테이너 포트 22를 호스트 포트 22에 프록시 장치를 추가하려고 했지만 "주소가 이미 사용 중입니다" 오류가 발생했습니다.
I have only a superficial understanding of networking technologies, I came from the side of the problem and try to solve it by poking at things with sticks.
나는 네트워킹 기술에 대해 피상적인 이해만 가지고 있으며, 문제의 측면에서 왔고, 막대기로 물건을 찔러서 해결하려고 합니다.
Simos Xenitellis 2021년 5월 6일 16:25
Author 저자
I mentioned LXD proxy devices and the ability for LXD to manage some
iptables
rules for your container as a way to show that it might be possible to add some firewall support (iptables) to ipvlan. It was more of a thought experiment rather than a suggestion that you can use proxy devices with ipvlan containers. In fact, you cannot use proxy devices with ipvlan containers, hence the errors that you get.LXD 프록시 장치와 LXD가 컨테이너에 대한 일부
iptables
규칙을 관리할 수 있는 능력을 언급한 것은 ipvlan에 방화벽 지원(iptables)을 추가할 수 있을지도 모른다는 것을 보여주기 위한 방법이었습니다. 이는 ipvlan 컨테이너와 함께 프록시 장치를 사용할 수 있다는 제안이라기보다는 사고 실험에 가까웠습니다. 사실, ipvlan 컨테이너와 함께 프록시 장치를 사용할 수 없으므로 발생하는 오류가 있습니다.If you use
ipvlan
containers just as a way to make a network service in that container available to the LAN, then you could consider using proxy devices instead (and let the container uselxdbr0
networking).컨테이너
ipvlan
를 LAN에서 해당 컨테이너의 네트워크 서비스를 사용할 수 있도록 만드는 방법으로만 사용한다면, 대신 프록시 장치를 사용하는 것을 고려할 수 있습니다(그리고 컨테이너가lxdbr0
네트워킹을 사용하도록 허용합니다).See https://blog.simos.info/how-to-use-the-lxd-proxy-device-to-map-ports-between-the-host-and-the-containers/ which explains how to make a Web server running in a standard container (
lxdbr0
) accessible from the LAN. The downside here is that the network port on the host must be free in order to create a proxy device. That is, if you want to create two web servers with proxy devices, then you need to use two different ports (such as 80 and 81) on the host.https://blog.simos.info/how-to-use-the-lxd-proxy-device-to-map-ports-between-the-host-and-the-containers/를 참조하세요. 이 링크는 표준 컨테이너 (
lxdbr0
)에서 실행되는 웹 서버를 LAN에서 접근 가능하게 만드는 방법을 설명합니다. 여기서 단점은 프록시 장치를 생성하기 위해 호스트의 네트워크 포트가 비어 있어야 한다는 것입니다. 즉, 프록시 장치가 있는 두 개의 웹 서버를 만들고 싶다면 호스트에서 두 개의 다른 포트(예: 80과 81)를 사용해야 합니다.Sergey 2021년 5월 6일 17:02
Ah, now I get it!
아, 이제 알겠어!
And yes, I already did it earlier as indicated in your article on the link, it helped me a lot earlier, works fine. However, yes, the problem is that one standard port for some service can be used only 1 time for 1 IP
Not that this is a huge problem, but I would like to make the services available in my containers by their default ports (each service by its own IP).
에 대해 한 번만 사용될 수 있다는 것입니다. 이것이 큰 문제는 아니지만, 나는 내 컨테이너에서 각 서비스가 자신의 IP로 기본 포트를 통해 서비스가 가능하도록 만들고 싶습니다.
그리고 네, 나는 이미 당신의 링크에 있는 기사에서 언급한 대로 이전에 그것을 했고, 그것은 나에게 많은 도움이 되었고, 잘 작동합니다. 그러나, 네, 문제는 일부 서비스에 대한 하나의 표준 포트가 1개의 IP
Also the limitation is that my host is connected to the local network only via WiFi (which, as far as I know, imposes some restrictions on the options for obtaining unique IP for containers).
또한 제한 사항은 내 호스트가 WiFi를 통해서만 로컬 네트워크에 연결되어 있다는 것입니다(내가 아는 한, 이는 컨테이너에 대한 고유 IP를 얻는 옵션에 일부 제한을 부과합니다).
By the way, does routed network have the same behavior as ipvlan with UFW?
그런데, 라우팅된 네트워크는 UFW와 함께 ipvlan과 동일한 동작을 하나요?
That is, by default, I also cannot implement what I described earlier, without any special settings?
즉, 기본적으로 특별한 설정 없이도 제가 이전에 설명한 내용을 구현할 수 없다는 건가요?
Unfortunately, I cannot verify this myself yet.
안타깝게도, 저는 아직 이것을 직접 확인할 수 없습니다.
Simos Xenitellis 2021년 5월 7일 15:23
Author 저자
If you can setup local DNS, then you can host all websites on a single server. That is, if your host is 192.168.1.10, and you are able to assign at your LAN’s DNS servers DNS names such as:
로컬 DNS를 설정할 수 있다면, 모든 웹사이트를 단일 서버에서 호스팅할 수 있습니다. 즉, 호스트가 192.168.1.10이고, LAN의 DNS 서버에 다음과 같은 DNS 이름을 할당할 수 있다면:
then you can use a reverse proxy with lxdbr0 and avoid setting up ipvlan/routed altogether.
그럼 lxdbr0와 함께 리버스 프록시를 사용하여 ipvlan/routed 설정을 완전히 피할 수 있습니다.
See https://www.linode.com/docs/guides/beginners-guide-to-lxd-reverse-proxy/ on how it can be done. Note that you do not setup Let’s Encrypt, therefore the steps are further simplified.
https://www.linode.com/docs/guides/beginners-guide-to-lxd-reverse-proxy/에서 어떻게 할 수 있는지 확인하세요. Let's Encrypt를 설정하지 않으므로 단계가 더욱 간소화됩니다.
Otherwise, you would use
routed
oripvlan
. These two are different and I think you need to setup rules on different chains.그렇지 않으면
routed
또는ipvlan
을 사용해야 합니다. 이 두 가지는 다르며, 서로 다른 체인에 대한 규칙을 설정해야 한다고 생각합니다.Sergey 2021년 5월 9일 11:12
Thanks for the suggestion, it solves some of the problems
제안해 주셔서 감사합니다. 그것은 일부 문제를 해결합니다
Please update the post with ipv6. Thank you in advance.
ipv6로 게시물을 업데이트해 주세요. 미리 감사드립니다.
Alexandr 2022년 8월 4일 10:17
I have 3 computers in LAN, 2 LXD containers inside 1st computer using ipvlan and a “hidden” container without ipvlan.
나는 LAN에 3대의 컴퓨터가 있고, 첫 번째 컴퓨터 안에 ipvlan을 사용하는 2개의 LXD 컨테이너와 ipvlan이 없는 "숨겨진" 컨테이너가 있다.
I can ping from containers to 2 other computers.
나는 컨테이너에서 다른 두 대의 컴퓨터에 핑을 보낼 수 있다.
I can ping from other computers to containers.
다른 컴퓨터에서 컨테이너로 핑을 보낼 수 있습니다.
No ping from ipvlan container to the host, but i can ping the host from “hidden” container.
ipvlan 컨테이너에서 호스트로의 핑이 없지만, "숨겨진" 컨테이너에서 호스트로 핑을 보낼 수 있습니다.
Ping from 1 ipvlan container to another says:
“ping: Do you want to ping broadcast? Then -b. If not, check your local firewall rules”
“ping: 브로드캐스트를 핑하고 싶으신가요? 그렇다면 -b를 사용하세요. 그렇지 않으면 로컬 방화벽 규칙을 확인하세요.”
What rules i shoud check?
어떤 규칙을 확인해야 하나요?
Containers are just created
컨테이너가 방금 생성되었습니다
Works for Debian 12: Debian 12에 대한 작업:
– echo ‘DNS=1.1.1.1 1.0.0.1’ > /etc/systemd/resolved.conf
– systemctl restart systemd-resolved