PlantUMLでネットワーク構成図を作成してみる

# PlantUMLとは
PlantUMLはオープンソースのUMLダイアグラム作成用のテキストベースの言語である（Wikiより抜粋）。UML（特にシーケンス図）を作成するときに良く用いられているらしいですが、ネットワーク構成図も作成できるということで使ってみました。

# まずはPlantUML使うための準備
PlantUMLを気軽に使うのは VSCodeが良いのでまずVSCodeは先に準備しておきましょう。
あと必要なもの。

1\. [VSCode](https://code.visualstudio.com/)
2\. [Microsoft Build of OpenJDK(OpenJDK 21)](https://learn.microsoft.com/ja-jp/java/openjdk/download)
3\. VSCode拡張モジュール [PlantUML](https://zenn.dev/m3ka24/articles/20220206-plantuml)

https://zenn.dev/m3ka24/articles/20220206-plantuml

# ネットワーク構成図を作成
少しだけ勉強して…

```text
@startuml

nwdiag {
   
    network Internal {
        address = "192.168.0.0/24";
        web [address = "192.168.0.1"];
        nas [address = "192.168.0.2"];
    }
}
@enduml
```

どうかな？？（Qiitaのmarkdownで描画）・・・できた！！簡単やｗ

```plantuml
nwdiag {
   
    network Internal {
        address = "192.168.0.0/24";
        web [address = "192.168.0.1"];
        nas [address = "192.168.0.2"];
    }
}
```

このサイトが勉強になる
https://plantuml.com/ja-dark/nwdiag

# ちょっと凝ってみる
アイコンとか色を使って少し本格的につくってみる。

```text
@startuml
!include <office/concepts/globe_internet>
!include <office/concepts/firewall>
!include <office/concepts/firewall_orange>
!include <office/Servers/application_server>
!include <office/Servers/database_server>
!include <office/Servers/web_server>
!include <office/Servers/virtual_server>
!include <office/Servers/virtual_web_server>
!include <office/Servers/virtual_web_server_blue>
!include <office/Servers/file_server>
!include <office/Servers/cluster_server>
!include <office/Servers/reverse_proxy>
!include <office/devices/router>
!include <office/devices/switch>
!include <office/devices/video_gateway>


nwdiag {
   
    internet [shape = cloud, description = "<$globe_internet>\n internet"];
    internet -- firewall;
    firewall [description = "<$firewall_orange>\n firewall"];

    network Internal {
        color = "pink";
        address = "192.168.0.0/24";
        firewall;
        ONU [address = "192.168.0.1", description = "<$router>\n ONU"];
        リブーター [address = "192.168.0.2"];
        ER605 [address = "192.168.0.3", description = "<$switch>\n ER605"];
        AdGuard  [address = "192.168.0.7", description = "<$reverse_proxy>\n AdGuard"];
        Synology_DS918 [address = "192.168.0.99", description = "<$file_server>\n webSynology_DS91801"];
        Proxmox8_1 [address = "192.168.0.10", description = "<$cluster_server>\n Proxmox8_1"];
        Proxmox8_2 [address = "192.168.0.20", description = "<$cluster_server>\n Proxmox8_2"];
    }

    network Proxmox8_1 {
        Proxmox8_1;
        host [address = "192.168.0.11", description = "<$virtual_server>\n host"];
        nginx [address = "192.168.0.13", description = "<$virtual_web_server>\n nginx"];
        apache [address = "192.168.0.12", description = "<$virtual_web_server_blue>\n apache"];
    }

    group {
        color = "#7777FF";

        Proxmox8_1;
        host;
        nginx;
        apache;
    }

    network Proxmox8_2 {
        Proxmox8_2;
        rokuge [address = "192.168.0.21", description = "<$video_gateway>\n rokuge"];
    }

    group {
        color = "#FFAAAA";

        Proxmox8_2;
        rokuge;
    }

    network VLAN1 {
        color = "green";
        address = "192.200.0.0/24";

        ER605  [address = "192.168.200.1"];
        web1 [address = "192.168.200.10", description = "<$web_server>\n web1"];
    }

    network VLAN2 {
        color = "green";
        address = "192.168.1.0/24";
        
        ER605  [address = "192.168.1.1"];
        web2 [address = "192.168.1.10", description = "<$web_server>\n web2"];
    }
}
@enduml
```

どうかな？？（Qiitaのmarkdownで描画）・・・正味１時間ぐらいで作成できた。すごいな。

```plantuml
!include <office/concepts/globe_internet>
!include <office/concepts/firewall>
!include <office/concepts/firewall_orange>
!include <office/Servers/application_server>
!include <office/Servers/database_server>
!include <office/Servers/web_server>
!include <office/Servers/virtual_server>
!include <office/Servers/virtual_web_server>
!include <office/Servers/virtual_web_server_blue>
!include <office/Servers/file_server>
!include <office/Servers/cluster_server>
!include <office/Servers/reverse_proxy>
!include <office/devices/router>
!include <office/devices/switch>
!include <office/devices/video_gateway>


nwdiag {
   
    internet [shape = cloud, description = "<$globe_internet>\n internet"];
    internet -- firewall;
    firewall [description = "<$firewall_orange>\n firewall"];

    network Internal {
        color = "pink";
        address = "192.168.0.0/24";
        firewall;
        ONU [address = "192.168.0.1", description = "<$router>\n ONU"];
        リブーター [address = "192.168.0.2"];
        ER605 [address = "192.168.0.3", description = "<$switch>\n ER605"];
        AdGuard  [address = "192.168.0.7", description = "<$reverse_proxy>\n AdGuard"];
        Synology_DS918 [address = "192.168.0.99", description = "<$file_server>\n webSynology_DS91801"];
        Proxmox8_1 [address = "192.168.0.10", description = "<$cluster_server>\n Proxmox8_1"];
        Proxmox8_2 [address = "192.168.0.20", description = "<$cluster_server>\n Proxmox8_2"];
    }

    network Proxmox8_1 {
        Proxmox8_1;
        host [address = "192.168.0.11", description = "<$virtual_server>\n host"];
        nginx [address = "192.168.0.13", description = "<$virtual_web_server>\n nginx"];
        apache [address = "192.168.0.12", description = "<$virtual_web_server_blue>\n apache"];
    }

    group {
        color = "#7777FF";

        Proxmox8_1;
        host;
        nginx;
        apache;
    }

    network Proxmox8_2 {
        Proxmox8_2;
        rokuge [address = "192.168.0.21", description = "<$video_gateway>\n rokuge"];
    }

    group {
        color = "#FFAAAA";

        Proxmox8_2;
        rokuge;
    }

    network VLAN1 {
        color = "green";
        address = "192.200.0.0/24";

        ER605  [address = "192.168.200.1"];
        web1 [address = "192.168.200.10", description = "<$web_server>\n web1"];
    }

    network VLAN2 {
        color = "green";
        address = "192.168.1.0/24";
        
        ER605  [address = "192.168.1.1"];
        web2 [address = "192.168.1.10", description = "<$web_server>\n web2"];
    }
}
```

# 感想
いまさらながらのUMLですが、昔はVISIOつかったりExcel使ったりして苦労した覚えがあります。自分、センスがないからそういう面でも苦労しました。PlantUMLで割と気軽に作れるのがわかり今後の設計資料に使えるなと思いましたｗ。

アイコンも割と豊富にあり綺麗に作れる。いいですね。

# 参考にさせて頂いたサイト様

https://techblog.raccoon.ne.jp/archives/1550550196.html

https://zaitakukinmu.com/2022/10/29/kubernetes-plantuml/#google_vignette

http://www.yosbits.com/wordpress/?page_id=9871

http://blockdiag.com/ja/nwdiag/index.html

https://qiita.com/tajirit/items/17c025b92c344a76daee