Get static IP to create HA in Synology NAS

try to get HA and Protainer CE working in Synology NAS DS420+ utilies container manager.

I created task schedule to successfully installed HA. only small issue is network is bridge mode that share my NAS IP. I perfer to get different static IP for HA. Not sure if it is possible. Reading net, someone suggest command but not working. As I am guru of coding. Try to get help from guru to correct my coding that runs in task schedule. So it can be easy upgrade when new HA version available.

The current working code is

docker run -d --name=home_assistant \
-e TZ=Australia/Sydney \
-v /volume1/docker/HAdata:/config \
--net=host \
--restart always \
homeassistant/home-assistant

it will create HA in bridge mode using NAS ip.

I try to add

    docker network create --driver bridge --subnet=192.168.10.0/24 my_net

code like

docker network create --driver bridge --subnet=192.168.10.0/24 my_net
docker run -d --net my_net --ip 192.168.10.10 --name=home_assistant \
-e TZ=Australia/Sydney \
-v /volume1/docker/HAdata:/config \
--net=host \
--restart always \
homeassistant/home-assistant

it doesn’t work. Anyone can help fix the coding

That won’t do what you are hoping to do. I run HA on Synology NAS.

a) use docker-compose instead. This way all your config is in a file

You want the HA container to have a separate IP from the Synology NAS? So for example, if the NAS has an IP address of 192.168.10.5. HA would be addressable at 192.168.10.6?

To do that you’d need to use a MAC VLAN in docker. I’ve never tried that.

Maybe take a step back first. The simplest is to use host networking for the HA container. What are the reasons / use cases that make the simplest approach not work?

Note: the Synology firewall may need rules added to it to allow docker bridge networks, etc., to route properly. If you have a problem try turning the firewall off, then figure out the right entry.

that is what I hope to achieve. When I use Qnap NAS, their docker can do by manually modify the IP address after installation via application mode.

Anyway, if it can’t be done. Then, I will leave as same as Synology NAS ip

Hello,

It can be done.
Check the synology firewall rules, not expert of this but with portainer or docker compose the compose yaml code is like

  Yourcontainer:
    image: dockercontainerimage
    container_name: yourname
    restart: always
    volumes:
      - /local/path/:/some/path
      - /local/path/:/data
# Ports section technically is not needed since using vlan means traffic can go trough all ports regardless of port mapping.
# Port mapping does not work with vlan. If you need any mapping/filtering/blacklisting/whitelisting etc. - do it on the firewall.
# However you can keep it commented as a placeholder for quick look-up which ports are being used by default if need be or getting rid of vlan.
   ports:
     - 8123:8123
#      - 
    networks:
      macvlanname:
        ipv4_address: 192.168.0.6(the adress you want homeassistant on)

networks:
  macvlanname:
    name: macvlanname
    driver: macvlan
    driver_opts:
      parent: yourinterfacename eg eth0
    ipam:
      config:
        - subnet: "192.168.0.0/24" your subnet
          ip_range: "192.168.0.6/32" your ip range /32=1 ip 24 =255 ips
          gateway: "192.168.0.1" your gateway

All this can be graphically setup in portainer under network section.
Then just put the homeassistant docker container from host network to macvlanname network.

Just do your test before going to production but it should work.

thanks. I am new for the protainer. have protainer installed. Will try.

After create network. I can’t deploy container with new network when set static ip. the error message is "
Failed starting container: user specified IP address is supported on user defined networks only".

Hello,

ok it might have something to do with the network not being created or being created twice, not sure.
Sincerely with the screenshot I am a bit lost.
Anyway in a compose way that it should be easier, at least is for me:

services:
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - /PATH_TO_YOUR_CONFIG:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    networks:
      - my-net

networks:
    my-net:
      driver: macvlan
      driver_opts:
        parent: ens160 #**Change this to your interface
      ipam:
        driver: default
        config:
          - subnet: 192.168.0.0/24     #**Your network subnet
            ip_range: 192.168.0.6/32  #**ip for container the /32=1 ip
            gateway: 192.168.16.1       #**Your network gateway

in this way is simpler, maybe.
you create a vlan with only one address that is the one you want.

Sorry but the screenshots were unclear to me.
Please note that you might not be able to ping 192.168.0.6 from the host 192.168.0.5, you have to do some modification in order to make it pingable as they are on the same physical host/network adapter.

I tried this exact compose file on a server to test and it works.

I hope it will help.

1 Like

Compose is the way to go. UI approaches are too problematic and not recreateable.

very appreciated your help. Base on your coding, I figured out that it is ip range settings that I made wrong.

Good to know you have got it working!