Docker

MAC address, VLAN, LAN, -d, --driver, --subnet, --ip-range, -o,

Naranjito 2021. 2. 23. 19:26
  • MAC address : A Media Access Control adress, a hardware identification number that uniquely identifies each device on a network, an unique identifier assigned to a network interface controller for use as a network address in comminications within a network segment. This use is common in most IEEE 802 networking technologies, including Ethernet, Wi-Fi, and Bluetooth.

 

  • VLAN : Virtual LAN, it allows network administrators to automatically limit access to a specified group of users by dividing workstation into different isolated LAN segments, an any broadcast domain that is partitioned and isolated in a computer netwdocork at the data link layer. When users move their workstations, administrators don't need to reconfigure the network or change VLAN groups. In a VLAN, the computers, servers, and other network devices are logically connected regadless of their physical location(knowllipop.com/pop-video?v=5f014949d4d8df8c9ad7fd32).

 

  • LAN : Local Area Network, a computer network that interconnects computers within a limited area such as a residence, school. 

 

  • docker network create -d macvlan --subnet=192.168.0.0/24 --ip-range=192.168.0.64/28 --gateway=192.168.0.1 -o macvlan_mode=bridge -o parent=eth0 my_macvlan

Some applications, especially legacy applications or applications which monitor network traffic, expect to be directly connected to the physical network. In this type of situation, you can use the macvlan network driver to assign a MAC address to each container's virtual network interface, making it appear to be a physical network interface directly connected to the physical network. In this case, you need to designate a physical interface on your Docker host to use for the macvlan, as well as the subnet and gateway of the macvlan.

docker network create -d macvlan --subnet=192.168.0.0/24 --ip-range=192.168.0.64/28 --gateway=192.168.0.1 -o macvlan_mode=bridge -o parent=eth0 my_macvlan
952127214f1e49a6a2c8d87962ee0d696729b687c4acfaee1eb7fb1cf3af2e25

-d or --driver : Driver, setting macvlan as network driver

 

--subnet : network for container

 

--ip-range : IP Range for host which supposed to be created MacVLAN

 

-o : Option

 

-o parent=eth0 : designate eth0 to parent interface of container network interface which will be created through MacVLAN, eth0 is network interface allocated from router

 

  • docker run -it --name c1 --hostname c1 --network my_macvlan ubuntu:14.04

Let's create container using MacVLAN network.

docker run -it --name c1 --hostname c1 --network my_macvlan ubuntu:14.04

root@c1:/# ip a

...

23: eth0@tunl0: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:c0:a8:00:40 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.64/24 brd 192.168.0.255 scope global eth0 //works well
       valid_lft forever preferred_lft forever

...