Create vitual ethernet Interface

Hi,
I would like to set up a Raspberry Pi with Network (eth0) and a virtual interface on this device. The reason is two applications running on port 80 and this would be the easiest way to solve this.
I searched around but can´t find a solution to set it up via HOST (NetworkManager) or via container . Is there an easy solution to do this or am I simply wrong and there is no way to do this with balena at the moment?

Thanks for the help!

Daniel

Hey Daniel,

If I’ve understood correctly, you have two containers, and both are running a process which listens on port 80?

If this is the case, you can use the ports field of the docker-compose to forward a different host port to the container’s port 80, like so:

services:
  service1:
    ...
    ports:
       - "80:80"
  service2:
    ...
    ports:
      - "8080:80"

In this simple example, service1 will have port 80 on the host OS open, and service2 will have port 8080 in the host OS forwarded to port 80 within the container.

Does this help?

Thanks for those information. I am aware of those features but in my case it’s required to run in different up ranges.
What I managed now is to create a virtual interface with ifconfig via host os. But if I wand to deploy devices it would be great to automate this.

Hi Daniel,

So from what I understand, you are creating an alias with ifconfig or ip that is called eth0:0. This is an obsolete way for doing this, since you may assign multiple IP addresses on a single interface now. You can do that with NetworkManager. If you search for NetworkManager multiple IP addresses you will come across a lot of answers. If you have any difficulties please let us know.

Okay, i solved this problem now.
I created a second IP for my interface:

nmcli connection modify my-ethernet1 ipv4.addresses $ip2
nmcli connection down my-ethernet1 && nmcli connection up my-ethernet1

Second I manged to connect the container to this specific IP with composer:

ports:
  - "192.168.101.200:53:53/tcp"
(...)

This now exactly work as expected.

Thanks for the support here btw!

Best regards