├── Dockerfile ├── README.md ├── gcm ├── gcmconf ├── hostroute2gns3 ├── images └── gcm.png ├── iourc.sample ├── mybuild.sh ├── myrun.sh ├── startup.sh └── winrun.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | # Version: 0.7.1 2 | FROM ubuntu:14.04 3 | MAINTAINER Valerio Di Giampietro "valerio@digiampietro.com" 4 | # 5 | # increase the version to force recompilation of everything 6 | # 7 | ENV GNS3LARGEVERSION 0.7.2 8 | # 9 | # ------------------------------------------------------------------ 10 | # environment variables to avoid that dpkg-reconfigure 11 | # tries to ask the user any questions 12 | # 13 | ENV DEBIAN_FRONTEND noninteractive 14 | ENV DEBCONF_NONINTERACTIVE_SEEN true 15 | # 16 | # ----------------------------------------------------------------- 17 | # install needed packages to build and run gns3 and related sw 18 | # 19 | RUN apt-get update 20 | RUN apt-get -y install git wget 21 | RUN apt-get -y install libpcap-dev uuid-dev libelf-dev cmake 22 | RUN apt-get -y install python3-setuptools python3-pyqt4 python3-ws4py 23 | RUN apt-get -y install python3-netifaces python3-zmq python3-tornado python3-dev 24 | RUN apt-get -y install bison flex 25 | # 26 | # for iou install 32 bit libraries, python is needed to generate the license file 27 | # 28 | RUN apt-get -y install lib32z1 lib32ncurses5 lib32bz2-1.0 29 | RUN apt-get -y install lxterminal telnet 30 | RUN apt-get -y install python 31 | RUN apt-get -y install wireshark cpulimit 32 | # 33 | # ----------------------------------------------------------------- 34 | # compile and install dynamips, gns3-server, gns3-gui 35 | # 36 | RUN mkdir /src 37 | RUN cd /src; git clone https://github.com/GNS3/dynamips.git 38 | RUN cd /src/dynamips ; git checkout v0.2.14 39 | RUN mkdir /src/dynamips/build 40 | RUN cd /src/dynamips/build ; cmake .. ; make ; make install 41 | # 42 | RUN cd /src; git clone https://github.com/GNS3/gns3-gui.git 43 | RUN cd /src; git clone https://github.com/GNS3/gns3-server.git 44 | RUN cd /src/gns3-server ; git checkout v1.2.3 ; python3 setup.py install 45 | RUN cd /src/gns3-gui ; git checkout v1.2.3 ; python3 setup.py install 46 | # 47 | #----------------------------------------------------------------------- 48 | # compile and install vpcs, 64 bit version 49 | # 50 | RUN cd /src ; \ 51 | wget -O - http://sourceforge.net/projects/vpcs/files/0.5/beta/vpcs-0.5b2-src.tbz/download \ 52 | | bzcat | tar -xvf - 53 | RUN cd /src/vpcs-*/src ; ./mk.sh 64 54 | RUN cp /src/vpcs-*/src/vpcs /usr/local/bin/vpcs 55 | # 56 | # -------------------------------------------------------------------- 57 | # compile and install iniparser (needed for iouyap) and 58 | # iouyap (needed to run iou without additional virtual machine) 59 | # 60 | RUN cd /src ; git clone http://github.com/ndevilla/iniparser.git 61 | RUN cd /src/iniparser ; make 62 | RUN cd /src/iniparser ; cp libiniparser.* /usr/lib ; \ 63 | cp src/iniparser.h /usr/local/include/ ; \ 64 | cp src/dictionary.h /usr/local/include/ 65 | # 66 | RUN cd /src ; git clone https://github.com/GNS3/iouyap.git 67 | RUN cd /src/iouyap ; make 68 | RUN cd /src/iouyap ; cp iouyap /usr/local/bin 69 | # 70 | # to run iou 32 bit support is needed so add i386 repository, cannot be done 71 | # before compiling dynamips 72 | # 73 | RUN dpkg --add-architecture i386 74 | RUN apt-get update 75 | RUN apt-get -y install libssl-dev:i386 76 | # 77 | # --------------------------------------------------------------------------- 78 | # install QEMU 79 | # 80 | RUN apt-get -y install qemu 81 | # 82 | # --------------------------------------------------------------------------- 83 | # install uml-utilities e iptables to be able to use tap0 device 84 | # and NAT 85 | # 86 | RUN apt-get -y install uml-utilities iptables 87 | # 88 | # --------------------------------------------------------------------------- 89 | # these links are needed to run IOU 90 | # 91 | RUN ln -s /usr/lib/i386-linux-gnu/libcrypto.so /usr/lib/i386-linux-gnu/libcrypto.so.4 92 | # 93 | # 94 | # prepare startup files /src/misc 95 | # 96 | RUN mkdir /src/misc 97 | # 98 | # install gnome connection manager 99 | # 100 | RUN cd /src/misc; wget http://kuthulu.com/gcm/gnome-connection-manager_1.1.0_all.deb 101 | #RUN cd /src/misc; wget http://va.ler.io/myfiles/deb/gnome-connection-manager_1.1.0_all.deb 102 | RUN apt-get -y install expect python-vte python-glade2 103 | RUN mkdir -p /usr/share/desktop-directories 104 | RUN cd /src/misc; dpkg -i gnome-connection-manager_1.1.0_all.deb 105 | RUN (while true;do echo;done) | perl -MCPAN -e 'install JSON::Tiny' 106 | RUN (while true;do echo;done) | perl -MCPAN -e 'install File::Slurp' 107 | #RUN cd /usr/local/bin; ln -s /usr/share/gnome-connection-manager/* . 108 | ADD gcmconf /usr/local/bin/gcmconf 109 | ADD startup.sh /src/misc/startup.sh 110 | ADD iourc.sample /src/misc/iourc.txt 111 | ADD gcm /usr/local/bin/gcm 112 | # Set the locale 113 | RUN locale-gen en_US.UTF-8 114 | ENV LANG en_US.UTF-8 115 | ENV LANGUAGE en_US:en 116 | ENV LC_ALL en_US.UTF-8 117 | RUN chmod a+x /src/misc/startup.sh 118 | ENTRYPOINT cd /src/misc ; ./startup.sh 119 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GNS3 1.2.3 docker image with VPCS, IOU, QEMU and Wireshark 2 | 3 | ### News 4 | 5 | 2015-01-20 Updated GNS3 to version 1.2.3 6 | 7 | 2014-12-06 Updated GNS3 to version 1.2.1, minor fixes 8 | 9 | 2014-11-20 Updated GNS3 to version 1.2 10 | 11 | 2014-11-15 Added support to be executed in Windows using [boot2docker](http://boot2docker.io/) and an X-Windows server like [Xming](http://www.straightrunning.com/XmingNotes/), [Cigwin/X](http://x.cygwin.com/) or similar software 12 | 13 | 2014-11-09 Added Gnome Connection Manager, routing to GNS3 emulated network, minor fixes 14 | 15 | 2014-10-27 Added QEMU emulator 16 | 17 | 2014-10-29 Added the tap0 network interface, owned by the current user, to allow connection to the physical world without need to be root 18 | 19 | 20 | ### Description 21 | 22 | This image is based on Ubuntu 14.04 and includes GNS3, VPCS, IOU Support, QEMU and Wireshark. For IOU emulation no additional Virtual Machine is required. 23 | 24 | VirtualBox is not included, there are some issues that I was not able to solve to run VirtualBox inside a Docker container. 25 | 26 | On image startup a new user is created with same username and user id of current user with the purpose of sharing the same home directory that the user has on the Linux machine. 27 | 28 | ### Usage 29 | 30 | A detailed tutorial is available at [digiampietro.com](http://www.digiampietro.com/2014/1109/cisco_network_emulation_gns3_docker_container.html) 31 | 32 | To start the image use the `myrun.sh` script, you will get a standard linux prompt, launch gns3 issuing the `gns3` command, you will have access to your home directory. For unknown reason, to me sometimes happen that the gns3 windows has black color covering readible areas, in that case exit and relauch gns3. 33 | The `myrun.sh` is avilable on my GitHub repository for [gns3-large](https://github.com/digiampietro/gns3-large): 34 | 35 | ``` 36 | #!/bin/sh 37 | 38 | export GDISPLAY=unix/$DISPLAY # forward X11 display to the host machine 39 | export GUSERNAME=`id -u -n` # current user's username 40 | export GUID=`id -u` # current user's user id 41 | export GGROUP=`id -g -n` # current user's primary group name 42 | export GGID=`id -g` # current user's primary group id 43 | export GHOME=$HOME # current user's home directory 44 | export GSHELL=$SHELL # current user's shell 45 | # 46 | # to connect the emulated network to the external world 47 | # we use a tap0 interface inside the docker container 48 | # connected to the GNS3 emulated network through 49 | # a GNS3 Cloud device attached to the tap0 interface 50 | # 51 | export GTAPIP=10.123.1.1 # the tap0 IP address 52 | export GTAPMASK=255.255.255.0 # the tap0 IP netmask 53 | export GTAPNATENABLE=0 # enable NAT on tap0 outgoing traffic (if 1 GROUTE2GNS3 must be 0) 54 | export GNS3NETWORK=10.123.0.0 # IP network used inside the GNS3 emulated network 55 | export GNS3NETMASK=255.255.0.0 # IP netmask used inside the GNS3 emulated network 56 | export GROUTE2GNS3=1 # enable routing from the container eth0 to the emulated network 57 | 58 | sudo docker run -h gns3-large \ 59 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 60 | -v $HOME:$HOME \ 61 | -e DISPLAY=$GDISPLAY \ 62 | -e GUSERNAME=$GUSERNAME \ 63 | -e GUID=$GUID \ 64 | -e GGROUP=$GGROUP \ 65 | -e GGID=$GGID \ 66 | -e GHOME=$HOME \ 67 | -e GSHELL=$SHELL \ 68 | -e GTAPIP=$GTAPIP \ 69 | -e GTAPMASK=$GTAPMASK \ 70 | -e GTAPNATENABLE=$GTAPNATENABLE \ 71 | -e GNS3NETWORK=$GNS3NETWORK \ 72 | -e GNS3NETMASK=$GNS3NETMASK \ 73 | -e GROUTE2GNS3=$GROUTE2GNS3 \ 74 | --privileged \ 75 | -it digiampietro/gns3-large 76 | 77 | ``` 78 | 79 | * `-h gns3-large` gives the hostname to the docker image 80 | * `-v /tmp/.X11-unix:/tmp/.X11-unix` is needed to display the application in the host environment 81 | * `-v $HOME:$HOME` mount your home directory inside the docker image (the `$HOME` evniroment variable must be correctly set) 82 | * `-e DISPLAY=unix/$DISPLAY` is needed to display the application int the host environment 83 | * `-e ... ` these options set environment variables used by the startup script to add the current user to the docker image. The $HOME and $SHELL environment variables must be correctly set and must contain users's home directory and user's shell 84 | * `--privileged` run in privileged mode, needed to use the tap0 network device to connect to the physical network 85 | * `-it digiampietro/gns3-large` starts the image with a controlling terminal 86 | 87 | The docker image, each time that starts, has the virtual interface MAC address changed, for this reason the `iourc.txt` file, containing the IOU License, must be regenerated. The startup script take care of this but you have to put the script `keygen.py` in the `gns3-misc/` folder inside your home directory. The generated `iourc.txt` file is put in `/src/misc/iourc.txt` (in the docker image file system). 88 | 89 | After image startup you have a standard linux prompt, type `gns3` to start the application or type exit to remain in the docker image with root access; to exit from the image type `exit` once more. 90 | 91 | In the docker image two nice tools are included to allow easier access to each device console 92 | 93 | * __Gnome Connection Manager__ a multi-tabbed terminal emulator with a list of hosts to connect to on the left panel (see image below), you can launch it with the _gcm_ command 94 | 95 | * __gcmconf__ a simple perl script that reads the GNS3 projects from your home directory and create or update the Gnome Connection Manager configuration file to include all devices in your emulated network as showin in the image below 96 | 97 | ![alt Gnome Connection Manage screenshot](https://raw.githubusercontent.com/digiampietro/gns3-large/master/images/gcm.png) 98 | 99 | To complete the setup of GNS3, launch the application `gns3` at the linux prompt, go to **Edit -> Preferences ...**: 100 | 101 | * in **General -> Console applications** replace the string __gnome-terminal__ with __lxterminal__ and then click on **Apply** and **OK**. This is needed because gnome-terminal can have some issues, related to dbus, inside the docker image; 102 | * in **IOS on UNIX -> General settings** put the string **`/src/misc/iourc.txt`** in **Path to IOURC (pushed to the server)** and then click on **Apply** and **OK** 103 | * in **Dynamips - IOS Routers** click __New__ and add your router images. For legal reasons these images cannot be bundled with the docker image, they have names like `c3725-adventerprisek9-mz.124-15.T14.image` or `c3640-jk9s-mz.124-16.image` or `c7200-adventerprisek9-mz.124-15.T14.image`. Google is your best friend 104 | * in **IOS on UNIX - IOU Devices** click __New__ and add your IOU images. For legal reasons these images cannot be bundled with docker image, they have names like `i86bi-linux-l2-adventerprisek9-15.1a.bin` or `i86bi-linux-l3-adventerprisek9-15.4.1T.bin`. 105 | 106 | ### Connection to the physical world 107 | To connect to the physical world and to the internet, a tap0 device, owned by the current user, is automatically created by the startup script. Because the `gns3` is not running as root, the only way to connect to external world is using the **cloud symbol** and the **tap0** device. 108 | When using the cloud symbol click on **Configure**, select the **NIO TAP** tab, write **tap0** in the field **TAP interface**, click on **Add** and then on **Apply** and **OK**. 109 | The tap0, virtual ethernet interface, by default (can be change editing the `myrun.sh` file): 110 | 111 | * has ip address 10.123.1.1 and netmask 255.255.255.0, can be change editing the `myrun.sh` file; 112 | * the router interface connected to the cloud symbol must have an ip address on the same subnet (for example 10.123.1.2/24) 113 | * assuming that the emulated network will use the network 10.123.0.0/16, routing, by default, has been configured on the docker container (can be changed and enable NAT instead); 114 | * a route to this network must be added on the host (unless NAT is used), can be done using the **hostroute2gns3** script included in this git repository; 115 | 116 | ## Author 117 | I am happy to be contacted about this project, my contact details are: 118 | 119 | |Item |Content | 120 | |-----------------|-------------------------------------------------| 121 | |Author's name |Valerio Di Giampietro | 122 | |Email |v@ler.io (yes it's a valid email address!) | 123 | |Personal web site|http://va.ler.io (aka http://digiampietro.com) | 124 | |LinkedIn |http://it.linkedin.com/in/digiampietro | 125 | |Twitter |http://twitter.com/valerio | 126 | |Facebook |http://facebook.com/digiampietro | 127 | 128 | ## License 129 | (The MIT License) 130 | 131 | Copyright (c) 2014 Valerio Di Giampietro [digiampietro.com](http://digiampietro.com) 132 | 133 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 134 | 135 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 136 | 137 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /gcm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # launch gnome connection manager in english 3 | export LANG=en_US.UTF-8 4 | export LANGUAGE=en_US:en 5 | export LC_CTYPE="en_US.UTF-8" 6 | /usr/share/gnome-connection-manager/gnome_connection_manager.py 7 | -------------------------------------------------------------------------------- /gcmconf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | $debug = 0; 3 | use JSON::Tiny; 4 | use File::Slurp; 5 | use Data::Dumper; 6 | use File::Basename; 7 | 8 | $hostskel = "[host _HOSTNUM_] 9 | group = _PRJNAME_ 10 | name = _HOSTNAME_ 11 | description = _HOSTDESCR_ 12 | host = 127.0.0.1 13 | user = 14 | pass = TaJ+mUvyoTJVZpSYZQTt1g+ygvGZTJfgN6VufubCkK4= 15 | private_key = 16 | port = _PORTNUM_ 17 | tunnel = 18 | type = telnet 19 | commands = 20 | keepalive = 0 21 | font-color = 22 | back-color = 23 | x11 = False 24 | agent = False 25 | compression = False 26 | compression-level = 6 27 | extra_params = 28 | log = False 29 | backspace-key = 0 30 | delete-key = 0"; 31 | 32 | 33 | $gcmconf = "$ENV{'HOME'}/.gcm/gcm.conf"; 34 | $prjdir = "$ENV{'HOME'}/GNS3/projects"; 35 | print STDERR "prjdir: $prjdir\n" if $debug; 36 | @prjfiles= glob("$prjdir/*"); 37 | 38 | for ($i=0; $i<=$#prjfiles; $i++) { 39 | $prjs[$i]=basename($prjfiles[$i]); 40 | $prjname{basename($prjfiles[$i])}=$i; 41 | } 42 | $,="\n"; 43 | print STDERR @prjfiles,"\n" if ($debug); 44 | print STDERR @prjs,"\n" if ($debug); 45 | 46 | # process the gcm.conf file 47 | print STDERR "opening: $gcmconf\n"; 48 | open (GCM,"$gcmconf") or die "Error opening $gcmconf file\n"; 49 | my $section=-1; 50 | while () { 51 | if (/^\[([^\]]+)]$/) { 52 | $secname=$1; 53 | $section++; 54 | print STDERR "section $section: $secname $_" if ($debug); 55 | $sec[$section] .= $_; 56 | $grpname[$section]="---undefined---"; 57 | } else { 58 | $sec[$section] .= $_; 59 | if (/^group \= (.*)$/) {$grpname[$section]=$1;} 60 | } 61 | } 62 | close GCM; 63 | 64 | 65 | # $VAR1 = { 66 | # 'name' => 'unsaved', 67 | # 'resources_type' => 'local', 68 | # 'topology' => { 69 | # 'nodes' => [ 70 | # { 71 | # 'properties' 72 | 73 | 74 | # ---------------------------------------------------------- 75 | # process project files 76 | $gcmhosts=""; 77 | $hostnum=1; 78 | for ($i=0; $i<=$#prjfiles; $i++) { 79 | undef $json; 80 | undef $h->{'topology'}->{'nodes'}; 81 | undef $h; 82 | undef $text; 83 | undef $n; 84 | $gns3file="$prjfiles[$i]/$prjs[$i].gns3"; 85 | unless (-e $gns3file) {next;} 86 | if ($prjs[$i]=~/untitled/) {next;} 87 | print STDERR "---- processing $gns3file\n"; 88 | $text = read_file($gns3file) or die "Error reading file $gns3file"; 89 | $json = JSON::Tiny->new; 90 | $h = $json->decode($text); 91 | $profilelist="Mrxvt.initProfileList: "; 92 | if ( $h->{'topology'}->{'nodes'} ) { 93 | for $k (sort keys $h->{'topology'}->{'nodes'}) { 94 | print STDERR "k: $k\n" if $debug; 95 | next unless ($h->{'topology'}->{'nodes'}[$k]->{'properties'}->{'name'}); 96 | next unless ($h->{'topology'}->{'nodes'}[$k]->{'properties'}->{'name'} !~ /Cloud /); 97 | 98 | $n=$k; 99 | $profilelist .="," unless ($n == 0); 100 | $profilelist .= $n; 101 | $s=$h->{'topology'}->{'nodes'}[$k]->{'properties'}->{'name'}; 102 | $p=$h->{'topology'}->{'nodes'}[$k]->{'properties'}->{'console'}; 103 | $tmpskel=$hostskel; 104 | $tmpskel=~s/_HOSTNUM_/$hostnum/; 105 | $tmpskel=~s/_PRJNAME_/$prjs[$i]/; 106 | $tmpskel=~s/_HOSTNAME_/$s/; 107 | $tmpskel=~s/_HOSTDESCR_/$s/; 108 | $tmpskel=~s/_PORTNUM_/$p/; 109 | $gcmhosts.=$tmpskel ."\n\n"; 110 | $hostnum++; 111 | } 112 | } 113 | 114 | } 115 | 116 | # print the $gcmconf file 117 | # 118 | print "Writing the new $gcmconf file\n"; 119 | open (GCM,">$gcmconf") or die "Error opening for write $gcmconf\n"; 120 | 121 | for ($i=0; $i < $#sec; $i++) { 122 | next if ($grpname[$i] ne '---undefined---'); 123 | print GCM $sec[$i]; 124 | } 125 | 126 | print GCM $gcmhosts; 127 | 128 | for ($i=1; $i < $#sec; $i++) { 129 | next if ($prjname{$grpname[$i]}); 130 | next if ($grpname eq '---undefined---'); 131 | if ($sec[$i] =~ /\[host \d+\]/sm) { 132 | $sec[$i] =~ s/\[host \d+\]/\[host $hostnum\]/sm; 133 | $hostnum++; 134 | } 135 | print GCM $sec[$i]; 136 | } 137 | 138 | print GCM $sec[$#sec]; 139 | -------------------------------------------------------------------------------- /hostroute2gns3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # routes from host to docker host and to gns3 emulated 4 | # environment 5 | # 6 | export GNS3NETWORK=10.123.0.0 7 | export GNS3NETMASK=255.255.0.0 8 | CID=`docker ps | grep gns3-large | awk '{print $1}'` 9 | echo Container ID: $CID 10 | CIDIP=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID` 11 | echo Container IP: $CIDIP 12 | ROUTEEXIST=`netstat -nr | awk '{print $1,$3}' | grep "$GNS3NETWORK $GNS3NETMASK"` 13 | if [ "$ROUTEEXIST" != "" ] 14 | then 15 | echo "removing existing route" 16 | route del -net $GNS3NETWORK netmask $GNS3NETMASK 17 | fi 18 | echo "adding route" 19 | route add -net $GNS3NETWORK netmask $GNS3NETMASK gw $CIDIP 20 | 21 | -------------------------------------------------------------------------------- /images/gcm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/digiampietro/gns3-large/578140bf06ca3e94f6ddcb8ac075d9f3efdbea02/images/gcm.png -------------------------------------------------------------------------------- /iourc.sample: -------------------------------------------------------------------------------- 1 | [license] 2 | gns3-large = 0123456789abcdef; 3 | -------------------------------------------------------------------------------- /mybuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | sudo docker build -t="digiampietro/gns3-large" . 3 | -------------------------------------------------------------------------------- /myrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export GDISPLAY=unix/$DISPLAY # forward X11 display to the host machine 4 | export GUSERNAME=`id -u -n` # current user's username 5 | export GUID=`id -u` # current user's user id 6 | export GGROUP=`id -g -n` # current user's primary group name 7 | export GGID=`id -g` # current user's primary group id 8 | export GHOME=$HOME # current user's home directory 9 | export GSHELL=$SHELL # current user's shell 10 | export GRUNXTERM=0 # start lxtermina, useful in windows 11 | # 12 | # to connect the emulated network to the external world 13 | # we use a tap0 interface inside the docker container 14 | # connected to the GNS3 emulated network through 15 | # a GNS3 Cloud device attached to the tap0 interface 16 | # 17 | export GTAPIP=10.123.1.1 # the tap0 IP address 18 | export GTAPMASK=255.255.255.0 # the tap0 IP netmask 19 | export GTAPNATENABLE=0 # enable NAT on tap0 outgoing traffic (if 1 GROUTE2GNS3 must be 0) 20 | export GNS3NETWORK=10.123.0.0 # IP network used inside the GNS3 emulated network 21 | export GNS3NETMASK=255.255.0.0 # IP netmask used inside the GNS3 emulated network 22 | export GROUTE2GNS3=1 # enable routing from the container eth0 to the emulated network 23 | 24 | sudo docker run -h gns3-large \ 25 | --rm \ 26 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 27 | -v $HOME:$HOME \ 28 | -e DISPLAY=$GDISPLAY \ 29 | -e GUSERNAME=$GUSERNAME \ 30 | -e GUID=$GUID \ 31 | -e GGROUP=$GGROUP \ 32 | -e GGID=$GGID \ 33 | -e GHOME=$GHOME \ 34 | -e GSHELL=$SHELL \ 35 | -e GTAPIP=$GTAPIP \ 36 | -e GTAPMASK=$GTAPMASK \ 37 | -e GTAPNATENABLE=$GTAPNATENABLE \ 38 | -e GNS3NETWORK=$GNS3NETWORK \ 39 | -e GNS3NETMASK=$GNS3NETMASK \ 40 | -e GROUTE2GNS3=$GROUTE2GNS3 \ 41 | -e GRUNXTERM=$GRUNXTERM \ 42 | --privileged \ 43 | -it digiampietro/gns3-large 44 | 45 | -------------------------------------------------------------------------------- /startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # add current user and user's primary group 4 | # 5 | groupadd -g $GGID $GGROUP 6 | useradd -u $GUID -s $GSHELL -c $GUSERNAME -g $GGID -M -d $GHOME $GUSERNAME 7 | usermod -a -G sudo $GUSERNAME 8 | echo $GUSERNAME:docker | chpasswd 9 | # 10 | # generate IOU License 11 | # 12 | if [ -e $GHOME/gns3-misc/keygen.py ] 13 | then 14 | cp $GHOME/gns3-misc/keygen.py /src/misc/ 15 | cd /src/misc 16 | ./keygen.py | egrep "license|`hostname`" > iourc.txt 17 | else 18 | echo "IOU License File generator keygen.py not found" 19 | echo "please put keygen.py in" 20 | echo "$GHOME/gns3-misc/keygen.py" 21 | fi 22 | # 23 | # create the tap device owned by current user 24 | # assign it an IP address, enable IP routing and NAT 25 | # 26 | echo "-------------------------------------------------------------------" 27 | echo "tap0 has address $GTAPIP netmask $GTAPMASK" 28 | echo "if yuou use the cloud symbol to connect to the physical network" 29 | echo "use an address on the same subnet, and, on the cloud symbol," 30 | echo "select the \"NIO TAP\" tab and add the \"tap0\" device" 31 | echo "-------------------------------------------------------------------" 32 | chmod 0666 /dev/net/tun 33 | chmod +s /usr/local/bin/iouyap 34 | tunctl -u $GUSERNAME 35 | ifconfig tap0 $GTAPIP netmask $GTAPMASK up 36 | echo 1 > /proc/sys/net/ipv4/ip_forward 37 | if [ "$GTAPNATENABLE" = "1" ] 38 | then 39 | echo "--- Enabling NAT on incoming ip on tap0 device" 40 | iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 41 | iptables -A FORWARD -i tap0 -j ACCEPT 42 | iptables -A INPUT -i tap0 -j ACCEPT 43 | fi 44 | if [ "$GROUTE2GNS3" = "1" ] 45 | then 46 | route add -net $GNS3NETWORK netmask $GNS3NETMASK gw $GTAPIP 47 | fi 48 | if [ "$GRUNXTERM" = "1" ] 49 | then 50 | # become the current user and start a shell 51 | su -l -c lxterminal $GUSERNAME 52 | # another root shel 53 | lxterminal 54 | else 55 | # become the current user and start a shell 56 | su -l $GUSERNAME 57 | # another root shell 58 | /bin/bash 59 | fi 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /winrun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # this script has to be executed in windows after installing 4 | # boot2docker, including MSYS-Git UNIX tools 5 | # that installation supports execution of /bin/bash scripts 6 | # 7 | set -e 8 | # clear the MSYS MOTD 9 | clear 10 | # 11 | # to connect the emulated network to the external world 12 | # we use a tap0 interface inside the docker container 13 | # connected to the GNS3 emulated network through 14 | # a GNS3 Cloud device attached to the tap0 interface 15 | # 16 | export GTAPIP=10.123.1.1 # the tap0 IP address 17 | export GTAPMASK=255.255.255.0 # the tap0 IP netmask 18 | export GTAPNATENABLE=1 # enable NAT on tap0 outgoing traffic (if 1 GROUTE2GNS3 must be 0) 19 | export GNS3NETWORK=10.123.0.0 # IP network used inside the GNS3 emulated network 20 | export GNS3NETMASK=255.255.0.0 # IP netmask used inside the GNS3 emulated network 21 | export GROUTE2GNS3=0 # enable routing from the container eth0 to the emulated network 22 | export GRUNXTERM=1 # start lxtermina, useful in windows 23 | 24 | # find main IP of Windows PC 25 | PCIP=`ping $COMPUTERNAME -n 1 | grep $COMPUTERNAME | grep '\[' | sed 's/^.*\[//' | sed 's/\].*//'` 26 | # if the home dir is /d/users/username modify to /c/users/username 27 | # because boot2docker maps only c:/users/username in /c/Users/username in docker 28 | GHOME=`echo $HOME | sed 's/^\/.\//\/c\//' | sed 's/users/Users/i'` 29 | echo "HOME: $HOME" 30 | echo "GHOME: $GHOME" 31 | echo "computername: $COMPUTERNAME" 32 | echo "IP: $PCIP" 33 | 34 | /c/Program\ Files/Boot2Docker\ for\ Windows/boot2docker.exe \ 35 | ssh "docker run \ 36 | --rm \ 37 | -h gns3-large \ 38 | -v $GHOME:/home/gns3user \ 39 | -e DISPLAY=$PCIP:0 \ 40 | -e GUSERNAME=gns3user \ 41 | -e GUID=1100 \ 42 | -e GGROUP=gns3user \ 43 | -e GGID=1100 \ 44 | -e GHOME=/home/gns3user \ 45 | -e GSHELL=/bin/bash \ 46 | -e GTAPIP=$GTAPIP \ 47 | -e GTAPMASK=$GTAPMASK \ 48 | -e GTAPNATENABLE=$GTAPNATENABLE \ 49 | -e GNS3NETWORK=$GNS3NETWORK \ 50 | -e GNS3NETMASK=$GNS3NETMASK \ 51 | -e GROUTE2GNS3=$GROUTE2GNS3 \ 52 | -e GRUNXTERM=$GRUNXTERM \ 53 | --privileged \ 54 | -it digiampietro/gns3-large" 55 | --------------------------------------------------------------------------------