Netkit Tutorial
Netkit Tutorial
Copyright notice
All the slides in this presentation, including but not limited to, images, photos, animations, videos, sounds, music, and text (hereby referred to as material) are protected by copyright This material, with the exception of some multimedia elements licensed by other organizations, is property of the authors and organizations appearing in the first slide This material, or its parts, can be reproduced and used for didactical purposes within universities and schools, provided that this happens for non-profit purposes Information contained in this material cannot be used within network design projects or other products of any kind Any other use is prohibited, unless explicitly authorized by the authors on the basis of a written agreement Authors assume no responsibility for the contents of this material, which may be subject to changes This copyright notice must always be redistributed together with the material, or its portions
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
Prerequisites
Very basic knowledge of the Linux OS Networking
iso-osi stack routing protocols (rip, bgp) basic network tools
10.1.0.10
Near native performance Good support for many guest OSes Emulates multiple architectures Comes with an accelerator module Lightweight
Plex86
Open Source
Outline
Understanding Netkit
Architecture overview
Setting up Netkit
Download and installation
Using Netkit
Getting acquainted with Netkit commands How to prepare Netkit labs
Sample scenarios
A virtual network running BGP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
Understanding Netkit
A Netkit network
virtual host virtual host
vhost:~# vhost:~#
virtual host
vhost:~#
virtual host
vhost:~#
virtual host
vhost:~#
virtual host
vhost:~#
virtual host
vhost:~#
virtual host
vhost:~#
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A Netkit network
virtual host virtual host
running routing daemon...
HOST OS
virtual host
GUEST OS
virtual hub
(collision domain)
host disk(s)
host ram
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
host NIC
HOST OS
virtual host
virtual host
ROUTER
virtual host
PC3
virtual hub
(collision domain)
PC2
(collision domain)
A few technicalities
Virtual machines run a user-mode-linux kernel
Linux kernel compiled for running as a userspace process Thin emulation layer better performance http://user-mode-linux.sourceforge.net/
Network Layer
Handled by the UML kernel IPv4/IPv6
Data-link Layer
Ethernet No collisions
Physical layer
Virtual hub daemon (uml_switch) Communication over unix sockets No delay, loss, reordering
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
Setting up Netkit
System requirements
Host CPU RAM i386 Linux host >600 MHz
lower freqs impact performance
A tiresome procedure
Just three steps 1. Download @ http://www.netkit.org
netkit-2.4.tar.bz2 netkit-filesystem-F2.2.tar.bz2 netkit-kernel-K2.2.tar.bz2
large file
A tiresome procedure
3. Set some environment variables
set NETKIT_HOME to the path where you installed Netkit set PATH to the string $PATH:$NETKIT_HOME/bin set MANPATH to the string :$NETKIT_HOME/man Example (using bash):
host machine host machine
foo@host:~/netkit$ foo@host:~/netkit$ foo@host:~/netkit$ foo@host:~/netkit$ export NETKIT_HOME=/home/foo/netkit/netkit2 export PATH=$PATH:$NETKIT_HOME/bin export MANPATH=:$NETKIT_HOME/man
Run check_configuration.sh
host machine host machine
foo@host:~/netkit$ cd netkit2 foo@host:~/netkit/netkit2$ ./check_configuration.sh ...... [ READY ] Congratulations! Your Netkit setup is now complete! Enjoy Netkit! foo@host:~/netkit/netkit2$
Using Netkit
(at last)
Vtools
vstart vconfig vlist vhalt vcrash vclean Start a virtual machine with a given configuration Attach a network interface to a running virtual machine List running virtual machines Gracefully shut down a virtual machine Kill a virtual machine Panic button
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
-M memory_amount -p
Just show what would be done
host machine host machine
--eth0=CD_A --eth1=CD_B foo@host:~$ vstart --eth0=CD_A --eth1=CD_B M 256 pc1 ============= Starting virtual machine "pc1" ============= /home/max/netkit2/kernel/netkitKernel: /home/max/netkit2/kernel/netkit-kernel Modules: /home/max/netkit2/kernel/modules ......
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A Netkit lab
is a set of pre-configured virtual machines that can be launched/stopped all together consists of a hierarchy of directories allows to set up complex network experiences can be controlled by using the ltools
Ltools
lstart ltest lhalt lcrash linfo lclean Start a Netkit lab or just some of its machines Start a Netkit lab in test mode Gracefully shut down (some of) the virtual machines of a lab Kill (some of) the virtual machines of a lab Display info about a lab without starting it; sketch the network topology Remove temporary files (no panic!)
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
My Own Lab, scene 1, take 1 Network topology Sketch your planned topology before implementing it
LEGEND
1 eth1
B
9 eth0
A
30.3.3.0/24
11.0.0.8/30 11.0.0.8/30
B
10 eth0
9 eth0
A
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
*AN
My Own Lab, scene 1, take 2 Network topology A lab consists of a hierarchy of directories Each (even empty) directory represents a virtual machine
host machine host machine
foo@host:~/lab$ as10r1 as10r2 foo@host:~/lab$ ls lab.conf
A lab consisting of two virtual machines (as10r1, as10r2) Check with linfo
Link-level connections are described inside the file lab.conf (in the lab root)
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
vm[opt]=val
opt: the name of a vstart option (e.g., mem) val: a value for that option
A
30.3.3.0/24
9 eth0
B
10 eth0
11.0.0.8/30
as10r1 as10r1
as10r1:~# pwd /root as10r1:~# ls this_is_a_file as10r1:~#
Ignition!
To start up a lab:
host machine host machine
foo@host:~$ cd lab foo@host:~/lab$ lstart
or
or
(.disk, .log):
or
A sample lab
A multihomed network
isp 1 isp 2
link 1
link 2
BGP
customer
(200.1.0.0/16)
RIP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A sample lab
A multihomed network, designed to:
Prohibit transit traffic
isp 1 isp 2
link 1
link 2
BGP
customer
(200.1.0.0/16)
RIP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A sample lab
A multihomed network, designed to:
isp 1 isp 2
link 1
link 2
customer
(200.1.0.0/16)
RIP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A sample lab
A multihomed network, designed to:
isp 1 isp 2
link 1
link 2
customer
(200.1.0.0/16)
RIP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
A sample lab
A multihomed network, designed to:
isp 1 isp 2
link 1
link 2
customer
(200.1.0.0/16)
RIP
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
ripd
ospfd
ospfd> ospfd>
zebra> zebra>
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
10 eth0
14 eth0 11.0.0.8/30
P
11.0.0.12/30
40.4.4.0/24
N
30.3.3.0/24 9 eth0
O
13 eth0
AS300
customer
(200.1.0.0/16) 2 2 eth0 eth1
1 2 eth0 eth1
1 eth1
1 eth1
Y
200.1.0.0/18
X
200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
10 eth0
14 eth0 11.0.0.8/30
P
11.0.0.12/30
40.4.4.0/24
N
30.3.3.0/24 9 eth0
O
13 eth0
AS300
as300r1 as300r1
customer
(200.1.0.0/16)
1 2 eth0 eth1
1 eth1
ping 11.0.0.26 ping ping 11.0.0.29 ping 1 2 2 eth0 eth1 traceroute 11.0.0.29 traceroute eth1 Y observeX nearest exit
200.1.64.0/18
200.1.0.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
10 eth0
14 eth0 11.0.0.8/30
P
11.0.0.12/30
40.4.4.0/24
N
30.3.3.0/24 9 eth0
O
13 eth0
AS300
as300r1 as300r1
customer
(200.1.0.0/16)
1 2 eth0 eth1
telnet localhost bgpd (pw:zebra) telnet 1 2 2 show ip bgp 1 show eth1 eth1 eth0 observe local routes eth1 the default and Yenable X enable show running-config show running200.1.0.0/18 200.1.64.0/18 observe prefix-lists that prevent prefix-
transit traffic and let /16 and200.1.128.0/17 /17 M be announced inspect ripd configuration
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
R
as30r1 as30r1
10 eth0 11.0.0.8/30
14 eth0
P
11.0.0.12/30
40.4.4.0/24
O
13 eth0
customer
9 eth0
AS300
customer
(200.1.0.0/16) 2 2 eth0 eth1
1 2 eth0 eth1
1 eth1
1 eth1
Y
200.1.0.0/18
X
200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30
as1r1 as1r1
30 traceroute eth0 traceroute 200.1.0.2
isp 1
S
25 eth2
AS30
1 eth1
isp 2
40.4.4.0/24
AS40 P
11.0.0.12/30
10 eth0
14 eth0 11.0.0.8/30
N
30.3.3.0/24 9 eth0
O
13 eth0
AS300
customer
(200.1.0.0/16) 2 2 eth0 eth1
1 2 eth0 eth1
1 eth1
1 eth1
Y
200.1.0.0/18
X
200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30
as1r1 as1r1
30 telnet eth0 telnet localhost bgpd (pw:zebra)
isp 1
S
25 eth2
show ip bgp show 11.0.0.28/30 Q observe the two /17s and the
29 two eth2
AS30
1 eth1
isp 2
AS40
1 eth1
10 eth0
14 eth0 11.0.0.8/30
P
11.0.0.12/30
40.4.4.0/24
N
30.3.3.0/24 9 eth0
O
13 eth0
AS300
customer
(200.1.0.0/16) 2 2 eth0 eth1
1 2 eth0 eth1
1 eth1
1 eth1
Y
200.1.0.0/18
X
200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
10 eth0
14 eth0 11.0.0.8/30
P
11.0.0.12/30
40.4.4.0/24
N
30.3.3.0/24 9 eth0
O
13
as300r1 as300r1
telnet localhost bgpd (pw:zebra) telnet eth0 AS300 enable enable configure terminal configure (200.1.0.0/16) router bgp 300 router 1 2 2 neighbor 11.0.0.10 shutdown neighbor eth1 eth0 eth1 simulating failure of link N Y shutting down the interface is X
customer
1 2 eth0 eth1
1 eth1
also 200.1.0.0/18
possible 200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
AS1
26 eth1 11.0.0.24/30 30 eth0
isp 1
S
25 eth2
Q
29 eth2
11.0.0.28/30
AS30
1 eth1
isp 2
AS40
1 eth1
R
as300r1 as300r1
10 eth0
14 eth0
P
11.0.0.12/30
40.4.4.0/24
11.0.0.8/30 after a while... N traceroute 11.0.0.25 traceroute 30.3.3.0/24 the backup route is being used 9 eth0
O
13 eth0
AS300
customer
(200.1.0.0/16) 2 2 eth0 eth1
1 2 eth0 eth1
1 eth1
1 eth1
Y
200.1.0.0/18
X
200.1.64.0/18
M
IPS MoMe 2006 - 2006 Massimo Rimondini & Compunet
200.1.128.0/17
Wanna play?
Visit http://www.netkit.org
Other ready-to-use labs Lecture slides Netkit updates Other resources (NetML)
Tha