{"id":1184,"date":"2022-08-20T14:39:34","date_gmt":"2022-08-20T06:39:34","guid":{"rendered":"https:\/\/blog.wallaceho.com\/?p=1184"},"modified":"2022-08-20T14:39:38","modified_gmt":"2022-08-20T06:39:38","slug":"setup-macvlan-on-docker-instance","status":"publish","type":"post","link":"https:\/\/blog.wallaceho.com\/?p=1184","title":{"rendered":"Setup MacvLAN on docker instance"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">After you created a docker instance, by default it will sharing the docker host default network interface IP address and port.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to create a virtual LAN for docker and getting static dedicated IP address from the same network as the host, you will need to setup a MacVLAN under the docker.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Simply use the below command to create a MacVLAN. But first, you will need to identify your host network interface, IP range, subnet and the DHCP configuration to avoid IP conflict. <\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-text-color\"><code>sudo docker network create -d macvlan -o -parent=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">eth0<\/mark> --subnet=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">192.168.81.0\/24<\/mark> --gateway=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">192.168.81.1<\/mark> --ip-range=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-blue-color\">192.168.81.8\/32<\/mark> new-macvlan<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1017\" height=\"449\" src=\"https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image.png\" alt=\"\" class=\"wp-image-1185\" srcset=\"https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image.png 1017w, https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image-300x132.png 300w, https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image-768x339.png 768w, https:\/\/blog.wallaceho.com\/wp-content\/uploads\/2022\/08\/image-500x221.png 500w\" sizes=\"auto, (max-width: 1017px) 100vw, 1017px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The next step is to create a bridge interface on the docker, you use any network which is not in use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, add both bridge network and macvlan network to the docker instance to get it work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After you created a docker instance, by default it will sharing the docker host default network interface IP address and port. If you want to create a virtual LAN for docker and getting static dedicated IP address from the same &hellip; <a href=\"https:\/\/blog.wallaceho.com\/?p=1184\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1184","post","type-post","status-publish","format-standard","hentry","category-computer"],"_links":{"self":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1184"}],"version-history":[{"count":3,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions"}],"predecessor-version":[{"id":1188,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=\/wp\/v2\/posts\/1184\/revisions\/1188"}],"wp:attachment":[{"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wallaceho.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}