ABR
Lab Creation
From the directory where you want to create your lab run:
koble lab init --name abr --author YOURNAME \
--description "abr example lab" \
--web EXAMPLE.COM
This will create a new lab directory called abr
with a lab.yml
lab config file.
Change directory into this lab and add machines to the lab:
cd abr
koble machine add a --network ar
koble machine add b --network br
koble machine add r --network ar --network br
We can now edit the startup files for the machines as follows:
#!/bin/bash
# Machine.startup - generated by koble machine add
# This is a script that will run when the machine boots
ip link set eth0 up
ip addr add 172.16.10.1/24 dev eth0
ip route add default via 172.16.10.254 dev eth0
#!/bin/bash
# Machine.startup - generated by koble machine add
# This is a script that will run when the machine boots
ip link set eth0 up
ip addr add 172.16.20.1/24 dev eth0
ip route add default via 172.16.20.254 dev eth0
#!/bin/bash
# Machine.startup - generated by koble machine add
# This is a script that will run when the machine boots
ip link set eth0 up
ip addr add 172.16.10.254/24 dev eth0
ip link set eth1 up
ip addr add 172.16.20.254/24 dev eth1
Starting the Lab
We can now start the lab. For now we will start it without launching terminals, as we can attach to the machines later.
koble lab start --launch=false
We can check that they are all running with:
koble list
# OR
koble ls
Using Koble Commands
There are three main ways of executing commands on a machine:
-
Attach
-
Shell
-
Exec
Attach
Attach allows us to attach to the main console of a machine. This is similar to how Netkit machines work by default. There is a single session where you can run one command at a time. Attaching and running commands is the standard way to use machines.
Use --terminal this to attach in the current shell, then press
<ctrl-p>, <ctrl-q> when you want to detach.
|
koble attach r
A terminal will open, connected to the console of machine r.
Check which network interfaces are available with
ip addr show
in this terminal.
You can now close this window.
You can reattach at any time when the machine is running.
Shell
Shell allows us to connect to a shell (usually an instance of bash
) on the
specified machine.
koble shell b
We can now try to ping machine a from the shell we have on machine b:
ping -c1 172.16.10.1
You can then exit the shell by running exit
.
Exec
If you wish to run a single command and don’t need a shell session,
you can use exec
.
For example, lets ping machine b from machine a:
koble exec a ping -c1 172.16.20.1
By default exec will use the terminal this (it will attach in
the current shell rather than a new terminal).
You can launch the command in a terminal, for example for gnome terminal:
koble --terminal gnome exec a ping -c1 172.16.20.1 .
Note that most terminals will close once the command has finished executing
so for short running processes you could miss the output.
|
You can now shutdown and remove all lab machines with:
koble lab destroy