# Macvlan

docker network create -d macvlan --subnet 192.168.43.0/24 --gateway 192.168.43.1 -o parent=enp3s0 -o macvlan\_mode=bridge macnet

```
docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
1c6d5e747213        bridge              bridge              local
6328f6098a1e        host                host                local
f50c8d5017f4        macnet              macvlan             local
4d16bce25ff7        none                null                local
677c13cd8d77        xoops_vpcbr         bridge              local
```

MACVLAN 有以下特點：

* 可讓使用者在同一張實體網卡上設定多個 Layer 2 address (一般就是 MAC address)
* 承上，帶有上述設定的 MAC address 的網卡稱為 sub interface，而實體網卡則稱為 parent interface
* 可在 parent/sub interface 上設定的不只是 MAC address，IP address 同樣也是可以被設定
* sub interface 無法直接與 parent interface 通訊 (帶有 sub interface 的 VM or container 無法與 host 直接通訊)
* 若 VM or container 需要與 host 通訊，那就必須額外建立一個 sub interface 給 host 用


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kawsing.gitbook.io/opensystem/docker-cong-an-zhuang-dao-ying-yong-ru-men-pian/macvlan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
