Export subnets from Meraki to phpIPAM

In order to populate phpIPAM I needed to export all subnets that was already present in Meraki Dashboard without type all information manually. I found PSMeraki module on Github which is a prerequisite for this script. The script creates a CSV that can be importet in to phpIPAM

$networks = Get-MrkNetwork
$subnets =@()

foreach ($network in $networks) {
    foreach ($vlan in $network) {
        $vlans = Get-MrkNetworkvlan -networkId $network.id

            foreach ($vlan in $vlans){

                    if (!$vlan.subnet){
            $sub = Get-Subnet $vlan.subnet

            $subnetname = $network.name + "_" + $vlan.name 
            [hashtable]$net = @{}

            $objVlan = New-Object -TypeName psobject -Property $net
            $subnets += $objVlan
$subnets | Export-Csv -Path subnets.csv -Delimiter ","

Docker and macvlan

If you want to use docker containers in your regular LAN subnet you need to setup a new Docker network with macvlan driver.

First create your Docker network. — ip-range specifies all addresses that Docker will manage. Chose a part of your subnet outside your DHCP-scoop if you have one to avoid ip conflicts.
–aux-address=’host=′ docker_net is tied to your host interface to allow your containers to comunicate with your host.

[root@docker01 ~]# docker network create -d macvlan -o parent=ens224 \
--subnet \
--gateway \
--ip-range \
--aux-address='host=' docker_net

As you can see when running docker network ls we have a new network called docker_net with macvlan driver.

Docker network

Next step is to create a macvlan interface, in this example called docker_int.
[root@docker01 ~]# ip addr add docker_int link ens224 type macvlan mode bridge

Configure the interface with your selected host address and bring it up. Last step is to add a IP route to tell your host how to connect to to al Docker containers.

[root@docker01 ~]# ip link add docker_int link ens224 type macvlan mode bridge
[root@docker01 ~]# ip link set docker-shim up
[root@docker01 ~]# ip route add dev docker_int

Run a container and connect it to docker_net
[root@docker01 ~]# docker run nginx -network docker_net

If you want to check container ip run:

[root@docker01 ~]# docker inspect CONTAINER_ID