Skip to content
This repository was archived by the owner on Jan 11, 2021. It is now read-only.

Commit 5fea009

Browse files
committed
Merge pull request #10 from nerdalert/enable_multi_net
bugfix, enabled 802.1q trunks and issue #7
2 parents ec37a65 + 7264b20 commit 5fea009

File tree

8 files changed

+241
-159
lines changed

8 files changed

+241
-159
lines changed

README.md

+50-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ipvlan-docker-plugin
1+
macvlan-docker-plugin
22
=================
33

44
This repo is for examples of a plugin w/ libnetwork and temporary until we get Ipvlan/Macvlan native driver support in Docker which will be
@@ -37,7 +37,7 @@ distribution repo or docker repos.
3737

3838
This example is also available in a [screencast on youtube](https://www.youtube.com/watch?v=IMOelqPzFtk).
3939

40-
**1.** Start Docker with the following or simply start the service. Version 1.9+ is required.
40+
**1.** Start Docker with the following or simply start the service. Version 1.9+ is required for 3rd party external network plugins.
4141

4242
```
4343
$ docker -v
@@ -52,20 +52,22 @@ $ docker daemon -D
5252
- *Note:* The host-interface flag is the Docker host's eth interface. It shouldnt be required for the driver but this is a bit lazy and isnt
5353
honoring docker network opts yet.
5454

55-
In the repo directory, use the binary named `macvlan-docker-plugin-0.2-Linux-x86_64`. Feel free to rename it :)
55+
In the repo directory, use the binary named `macvlan-docker-plugin-0.3-Linux-x86_64`. Feel free to rename it :)
5656

5757
```
5858
$ git clone https://github.com/gopher-net/macvlan-docker-plugin.git
5959
$ cd macvlan-docker-plugin/binaries
60-
$ ./macvlan-docker-plugin-0.2-Linux-x86_64 -d
60+
$ ./macvlan-docker-plugin-0.3-Linux-x86_64 -d --host-interface=eth1 --mode=bridge
6161
6262
# -d is debug
63+
# --host-interface is the master interface, eth0, eth1 etc. The docker network create needs to correspond to that subnet for bridge mode
6364
```
6465

6566
**3.** Create a network with Docker
6667

6768
**Note** the subnet needs to correspond to the master interface. In this example, the nic `eth1` is attached to a subnet `192.168.1.0/24`. The container needs to be on the same *broadast domain* as the default gateway. In this case it is a router with the address of `192.168.1.1`.
6869

70+
6971
```
7072
$ docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o host_iface=eth1 net1
7173
```
@@ -75,10 +77,50 @@ $ docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1
7577
Run some containers, specify the network and verify they can ping one another
7678

7779
```
78-
$ docker run --net=net1 -it --rm ubuntu
80+
$ docker run --net=net1 -it --rm debian
81+
```
82+
83+
Docker networks are now persistant after a reboot. The plugin does not currently support dealing with unknown networks. That is a priority next. To remove all of the network configs on a docker daemon restart you can simply delete the directory with: `rm /var/lib/docker/network/files/*`
84+
85+
86+
### 802.1q Trunks with MacVlan
87+
88+
**Note** Containers using the **same** parent interface e.g. `eth1.20` can reach one another without an external router (intra-vlan). Containers on different VLANs/parent interfaces can not reach one another without an external router (inter-vlan).
89+
90+
### Vlan ID 20
91+
92+
```
93+
# create a new subinterface tied to dot1q vlan 20
94+
ip link add link eth1 name eth1.20 type vlan id 20
95+
96+
# enable the new sub-interface
97+
ip link set eth1.20 up
98+
99+
# now add networks and hosts as you would normally by attaching to the master (sub)interface that is tagged
100+
docker network create -d macvlan --subnet=192.168.20.0/24 --gateway=192.168.20.1 -o host_iface=eth1.20 macvlan20
101+
docker run --net=macvlan20 -it --name mcv_test1 --rm debian
102+
docker run --net=macvlan20 -it --name mcv_test2 --rm debian
103+
104+
# mcv_test1 should be able to ping mcv_test2 now.
105+
```
106+
107+
### Vlan ID 30
108+
109+
```
110+
# create a new subinterface tied to dot1q vlan 30
111+
ip link add link eth1 name eth1.30 type vlan id 30
112+
113+
# enable the new sub-interface
114+
ip link set eth1.30 up
115+
116+
# now add networks and hosts as you would normally by attaching to the master (sub)interface that is tagged
117+
docker network create -d macvlan --subnet=192.168.30.0/24 --gateway=192.168.30.1 -o host_iface=eth1.30 macvlan30
118+
docker run --net=macvlan30 -it --name mcv_test3 --rm debian
119+
docker run --net=macvlan30 -it --name mcv_test4 --rm debian
120+
121+
# mcv_test3 should be able to ping mcv_test4 now.
79122
```
80123

81-
Docker networks are now persistant after a reboot. To remove all of the network configs on a docker daemon restart you can simply delete the directory with: `rm /var/lib/docker/network/files/*`
82124

83125
### Notes and General Macvlan Caveats
84126

@@ -92,7 +134,7 @@ Docker networks are now persistant after a reboot. To remove all of the network
92134

93135
### Dev and issues
94136

95-
To run the plugin via Go for hacking simply run go with the `main.go` entry point and desired parameters. The same applies to the [gopher-net/ipvlan](https://github.com/gopher-net/ipvlan-docker-plugin) driver:
137+
To run the plugin via Go for hacking simply run go with the `main.go`. The same applies to the [gopher-net/ipvlan](https://github.com/gopher-net/ipvlan-docker-plugin) driver:
96138

97139
```
98140
go run main.go -d
@@ -132,4 +174,4 @@ go get github.com/tools/godep
132174
git clone https://github.com/docker/libnetwork.git
133175
cd libnetwork
134176
godep restore
135-
```
177+
```
-8.79 MB
Binary file not shown.

binaries/macvlan-docker-plugin-0.3-Linux-x86_64

Whitespace-only changes.

plugin/Godeps/Godeps.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugin/macvlan/cli.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ import "github.com/codegangsta/cli"
55
// Exported Flag Opts
66
var (
77
// FlagMacvlanMode TODO: Values need to be bound to driver. Need to modify the Driver iface. Added brOpts if we want to pass that to Listen(string)
8-
FlagMacvlanMode = cli.StringFlag{Name: "mode", Value: macvlanMode, Usage: "name of the macvlan mode [bridge|private|passthrough|vepa]. By default, bridge mode is implicit: --bridge-name=bridge"}
9-
FlagGateway = cli.StringFlag{Name: "gateway", Value: gatewayIP, Usage: "IP of the default gateway. default: --bridge-ip=172.18.40.1/24"}
8+
FlagMacvlanMode = cli.StringFlag{Name: "mode", Value: macvlanMode, Usage: "name of the macvlan mode [bridge|private|passthrough|vepa]. By default, bridge mode is implicit: --bridge-name=bridge"}
9+
// FlagGateway = cli.StringFlag{Name: "gateway", Value: gatewayIP, Usage: "IP of the default gateway. default: --bridge-ip=172.18.40.1/24"}
1010
FlagBridgeSubnet = cli.StringFlag{Name: "macvlan-subnet", Value: defaultSubnet, Usage: "subnet for the containers (currently IPv4 support)"}
11-
FlagMacvlanEth = cli.StringFlag{Name: "host-interface", Value: macvlanEthIface, Usage: "the ethernet interface on the underlying OS that will be used as the parent interface that the container will use for external communications"}
11+
12+
// FlagMacvlanEth = cli.StringFlag{Name: "host-interface", Value: macvlanEthIface, Usage: "the ethernet interface on the underlying OS that will be used as the parent interface that the container will use for external communications"}
1213
)
1314

1415
// Unexported variables
1516
var (
1617
// TODO: align with dnet-ctl for bridge properties.
17-
macvlanMode = "bridge" // currently only mode supported. Does anyone use the others?
18-
macvlanEthIface = "eth1" // parent interface to the macvlan iface
19-
defaultSubnet = "192.168.1.0/24" // magic default /24 for demo/testing
20-
gatewayIP = "192.168.1.1" // this is the address of an external route
21-
cliMTU = 1500 // generally accepted default MTU
18+
macvlanMode = "bridge" // currently only mode supported. Does anyone use the others?
19+
// macvlanEthIface = "eth1" // parent interface to the macvlan iface
20+
defaultSubnet = "192.168.1.0/24" // magic default /24 for demo/testing
21+
// gatewayIP = "192.168.1.1" // this is the address of an external route
22+
cliMTU = 1500 // generally accepted default MTU
2223
)

0 commit comments

Comments
 (0)