Last active
December 1, 2019 23:28
-
-
Save milosgajdos/9f68b1818dca886e9ae8 to your computer and use it in GitHub Desktop.
Revisions
-
milosgajdos revised this gist
Dec 4, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import ( func main() { // CREATE VLAN HOST INTERFACE vlanDocker, err := tenus.NewVlanLinkWithOptions("eth1", tenus.VlanOptions{Dev: "vlanDckr", Id: 20}) if err != nil { log.Fatal(err) } -
milosgajdos revised this gist
Jul 28, 2014 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,6 @@ func main() { } // PASS VLAN INTERFACE TO A RUNNING DOCKER BY PID pid, err := tenus.DockerPidByName("vlandckr", "/var/run/docker.sock") if err != nil { fmt.Println(err) -
milosgajdos revised this gist
Jul 13, 2014 . 1 changed file with 6 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,29 @@ package main import ( "fmt" "log" "net" "github.com/milosgajdos83/tenus" ) func main() { // CREATE VLAN HOST INTERFACE vlanDocker, err := tenus.NewVlanLinkWithOptions("eth1", tenus.VlanOptions{VlanDev: "vlanDckr", Id: 20}) if err != nil { log.Fatal(err) } // PASS VLAN INTERFACE TO A RUNNING DOCKER BY PID // docker run -i -t --rm --privileged --name vlandckr ubuntu:14.04 /bin/bash pid, err := tenus.DockerPidByName("vlandckr", "/var/run/docker.sock") if err != nil { fmt.Println(err) } if err := vlanDocker.SetLinkNetNsPid(pid); err != nil { log.Fatal(err) } // ALLOCATE AND SET IP FOR THE NEW DOCKER INTERFACE @@ -34,7 +32,7 @@ func main() { log.Fatal(err) } if err := vlanDocker.SetLinkNetInNs(pid, vlanDckrIp, vlanDckrIpNet, nil); err != nil { log.Fatal(err) } } -
milosgajdos created this gist
Jun 28, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ // +build amd64 package main import ( "fmt" "log" "net" "github.com/milosgajdos83/docknet" ) func main() { // CREATE VLAN HOST INTERFACE vlanDocker, err := docknet.NewVlanLinkWithOptions("eth1", docknet.VlanOptions{VlanDev: "vlanDckr", Id: 20}) if err != nil { log.Fatal(err) } // PASS VLAN INTERFACE TO A RUNNING DOCKER BY PID // docker run -i -t --rm --privileged --name vlandckr ubuntu:14.04 /bin/bash // docker inspect --format='{{ .State.Pid }}' vlandckr pid, err := docknet.DockerPidByName("vlandckr") if err != nil { fmt.Println(err) } if err := vlanDocker.SetLinkNsPid(pid); err != nil { fmt.Println(err) } // ALLOCATE AND SET IP FOR THE NEW DOCKER INTERFACE vlanDckrIp, vlanDckrIpNet, err := net.ParseCIDR("10.1.41.3/16") if err != nil { log.Fatal(err) } if err := vlanDocker.SetNsNetwork(pid, vlanDckrIp, vlanDckrIpNet, nil); err != nil { log.Fatal(err) } }