GNS3¶
Setting up GNS3¶
Enable Port Forwarding¶
- First, you need to setup port forwarding to ports which are used by GNS3. Open a new terminal on Sahara PC, and edit the
~/.ssh/config:
Host ntnu_server
HostName team<your_team_number>.ttm4200.iaas.iik.ntnu.no
User <your_NTNU_username>
IdentityFile ~/.ssh/<key_name>
LocalForward 3080 localhost:3080
LocalForward 5000 localhost:5000
LocalForward 5001 localhost:5001
LocalForward 5002 localhost:5002
LocalForward 5003 localhost:5003
LocalForward 5004 localhost:5004
LocalForward 5005 localhost:5005
LocalForward 5006 localhost:5006
LocalForward 5007 localhost:5007
LocalForward 5008 localhost:5008
LocalForward 5009 localhost:5009
LocalForward 5010 localhost:5010
LocalForward 5011 localhost:5011
LocalForward 5012 localhost:5012
LocalForward 5013 localhost:5013
LocalForward 5014 localhost:5014
LocalForward 5015 localhost:5015
LocalForward 5016 localhost:5016
LocalForward 5017 localhost:5017
LocalForward 5018 localhost:5018
LocalForward 5019 localhost:5019
LocalForward 5020 localhost:5020
LocalForward 5021 localhost:5021
LocalForward 5022 localhost:5022
LocalForward 5023 localhost:5023
LocalForward 5024 localhost:5024
LocalForward 5025 localhost:5025
LocalForward 5026 localhost:5026
LocalForward 5027 localhost:5027
LocalForward 5028 localhost:5028
LocalForward 5029 localhost:5029
LocalForward 5030 localhost:5030
LocalForward 5031 localhost:5031
LocalForward 5032 localhost:5032
LocalForward 5033 localhost:5033
LocalForward 5034 localhost:5034
- This is just an arbitrary number of ports which GNS3 may use at some point. You may require only a few of them, or you might need even more. In that case, add more lines to your SSH configuration file.
Update GNS3-Server¶
-
Check the version of GNS3-Client on Sahara PC:
- Open GNS3 on the Sahara PC.
- Locate "Running GNS3 version x.y.z" in the console.
- Take note of the version number, i.e. "x.y.z" from above.
-
Check the version of GNS3-Server on "ntnu_server":
- In the terminal of "ntnu_server", enter the command
gns3server -v. - Compare with the client version.
- If the version numbers are identical, you may skip to the next subsection (Configure GNS3 Client).
- In the terminal of "ntnu_server", enter the command
-
If the GNS3-Client version is newer than GNS3-Server:
- In the terminal of "ntnu_server", enter the command
sudo apt update && sudo apt install --only-upgrade gns3-server. - Continue to the next subsection (Configure GNS3 Client).
- In the terminal of "ntnu_server", enter the command
-
If the GNS3-Server version is newer than GNS3-Client:
- To update the GNS3-Client version on Sahara PCs, the TAs will need to contact the IT support. Please inform them if this is the case.
- After the newest version is installed, you can continue to the next subsection (Configure GNS3 Client).
- If updating the GNS3-Client is unavailable, you may proceed with the lab on your own computer. Install the newest version of GNS3-Client.
- Remember to setup
~/.ssh/configon your computer, as well as a SSH key for more convenient access. Consider using Windows Subsystem for Linux (WSL) if running a Windows computer. - You may instead attempt to downgrade the GNS3-Server version at your own risk.
Configure GNS3 Client¶
-
Open GNS3 (can be found in Applications) on Sahara PC and configure your local GNS3 installation:
- Locate: Edit -> Preferences -> Server (Or Controller)
- Untick Enable local server
- Protocol: HTTP
- Host: localhost
- Port: 3080 TCP
- Untick Auth
-
Reconnect to your ntnu_server, such that the open ports take effect. Make sure that GNS3 connects to your VM under Servers Summary.
-
When opening GNS3 you will be prompted to make a new project, you can close this tab as we will import a pre-made project.
-
Import the
lab<lab_number>.gns3projectas a portable project in GNS3 to view the topology, access the containers, and start packet captures. You can do that in File -> Import portable project.
Warning
When you import a GNS3 portable project again (i.e., after making changes and saving configurations), your previous modifications are lost because importing a project extracts a fresh copy from the archive, discarding any changes you made. Instead, when continuing work on an existing project, open it via File -> Open project -> Projects library.
-
Start all the devices in GNS3 with "Start/Resume all nodes" button.
-
You can access a terminal of a container from GNS3 by double clicking the container.
Tip
To copy the files from the containers to the "ntnu_server", you can use the sudo cp "$(sudo find /opt/gns3/projects -name <filename>)" . command in "ntnu_server". Change "<filename>" to the name of your file.
Note
In order to save certain configurations on the containers when using GNS3, you need to run the save script provided in the home directory (~). Use ./save.sh to run it. This will save any nft and vtysh configuration. If you relaunch the GNS3 project without saving, these configurations will be lost. Have a look at the script to understand how to save such configurations.
- You can still use
docker attachalong with the generated name for the container (found withdocker ps) in your VM in order to access the containers, as long as the topology is started in GNS3. If you want to detach, pressCtrl+pfollowed byCtrl+q, as usual.