I’m sure you’re cruising YouTube for the perfect video to help you deploy X container, but the problem is you can’t get it to work because it needs a dedicated IP address, or you want it to operate on standard ports. There are two options to consider. “macvlan” or “ipvlan”, for quick learning purposes ipvlan shares the mac host address while macvlan uses a dedicated mac address per IP. So it’s up to you or your software if this feature is needed.

To setup either you login as an admin to Portainer and navigate to the server you wish to configure a network on (if you have a single server this can be ignored) and clicking on “Networks” then clicking on “Add Network”. The menu that pops up you first want to name your network. I suggest a naming profile such as macvlan.vlan1.base, but you can name it anything you want adhering to the formatting that’s required. Then set driver to macvlan. Set “Parent Network Card” to whatever the OS calls the interface. It could be as simple as eth0 or ens0p1 etc.

You’ll set your subnet; in most cases this is likely your home network. 192.168.1.0/24 for example. You’ll set the gateway which is usually the first IP on your network unless you think setting it to .254 somehow increases security (Hint it never does it’s just lolz for hackers). You can leave IP range blank.

Excluded IP’s. If you have internal servers you do not want to accidentally use it’s IP then you’ll do this hear. Click the + to add an exclusion and use the format

server=192.168.1.10

xyz=192.168.1.11

One entry per line as many as you need.

Then click “create the network”.

Then go back and click add network again and again and this time I set a name of macvlan.vlan1.subnet

Select driver of macvlan again, but this time after selecting macvlan driver were going to click on the blue creation tab.

Now we have a menu item below called “Configuration” which we will select the dropdown of macvlan.vlan1.base and then just hit “create the network” at the bottom.

Now when we create a device that needs a dedicated IP, under the network tab, we select macvlan.vlan1.subnet and go down and set the ip and dns servers and you’re good to go.

Don’t forget if you’re using a stack template to add variables for the subnet so it can setup the ip address.

You’ll have to repeat this if your device is using vlan’s on its NIC. So eth0 might be the default vlan which is usually 1, but eth0.2 might be vlan 2, so when making a macvlan for vlan 2 you’ll set the interface to be eth0.2 or ens0v2 whatever the naming convention is for the subnet’s vlan as setup in the OS.