Sie sind auf Seite 1von 45

Netkit

The poor man's system for experimenting computer networking

some rights reserved

Experimenting with Computer Networks

computer networks are quite complex


different machines like hosts, routers etc. several network interfaces several protocols complex topologies

performing experiments may be difficult

network equipment is expensive.

some rights reserved

User Mode Linux

Netkit is based on virtual machines which can be run as applications on a standard linux machine Each VM is a full fledged linux machine with

a console memory cut into the host's memory virtual network interfaces etc.
some rights reserved

Starting a simple VM
sabu@laptop$ vstart pc1

PC1

some rights reserved

Starting a simple VM
sabu@laptop$ vstart pc1

How to halt a virtual machine?


PC1

some rights reserved

Starting a VM with an ethernet interface eth0


sabu@laptop$ vstart pc1 --eth0=CD1

What is a collision domain? Set IP address of PC1 to 192.168.1.5


PC1 eth0

CD1

some rights reserved

Simple Shell commands

Setting IP address ifconfig Setting Route route Echo Reply ping Packet Sniffing tcpdump Trace packet route - traceroute

some rights reserved

Setting the IP address of PC1


pc1# ifconfig eth0 192 1!" 1 #

PC1

eth0
192.168.1.5 CD1

some rights reserved

Starting a second VM
sabu@laptop$ vstart pc2 --eth0=CD1
CD1

PC1

eth0
192.168.1.5

PC2

eth0

some rights reserved

Set IP address of PC2


pc2# ifconfig eth0 192 1!" 1 !
CD1

PC1

eth0
192.168.1.5

PC2

eth0
192.168.1.6

some rights reserved

Check connection- PING


pc2# ping 192 1!" 1 #
CD1

PC1

eth0
192.168.1.5

PC2

eth0
192.168.1.6

some rights reserved

ARP Table
pc2# arp

What will be the output?


CD1

PC1

eth0
192.168.1.5

PC2

eth0
192.168.1.6

some rights reserved

Packet Analysis
pc2# tcpdump -i eth0

TCPDUMP listens on the interface eth0 captures all packets arriving there

some rights reserved

Packet Analysis
pc2# tcpdump -i eth0

TCPDUMP listens on the interface eth0 captures all packets arriving there packet details can be saved to file and analyzed with WIRESHARK.

pc2# tcpdump -i eth0 -$ %hosthome%pac&ets pcap


some rights reserved

Enter the Router


192.168.1.5 PC1 eth0

more than one interface

sabu@laptop$ vstart router1 --eth0=cd1 --eth1=cd2

PC2

eth0 ROUTER 1

192.168.1.6

eth0

eth1

CD1

CD2
some rights reserved

Set IP address of Router 1


192.168.1.5 PC1 eth0

more than one interface


eth0 1 1 eth1 2 1

PC2

eth0

router1# ifconfig 192 1!" router1# ifconfig 192 1!"


ROUTER 1

192.168.1.6

eth0 192.168.1.1

eth1 192.168.2.1

CD1

CD2
some rights reserved

Create Subnet 2
192.168.1.5 PC1 eth0 eth0 192.168.2.5 PC3

NIC

PC2

eth0 ROUTER 1

192.168.1.6

eth0

eth1

CD1

192.168.1.1

192.168.2.1

CD2
some rights reserved

Check connectivity

Try pinging PC3 from PC1. What happens?

some rights reserved

Check connectivity

Subnet 2 not reachable from Subnet 1 and vice versa. WHY?

some rights reserved

Check connectivity

Set default gateway for PC1 and ping PC3. What happens now?
pc1# route add default g$ 192 1!" 1 1

some rights reserved

Check connectivity

Set default gateway for PC1 and ping PC3. What happens now? Ping makes its way to subnet 2 but cannot find its way back! Set default gateway for PC3 as well.

pc'# route add default g$ 192 1!" 2 1

some rights reserved

ARP in Action

Run TCPDUMP on PC3 and Router1's eth0 (one machine in each subnet) Ping PC3 from PC1

some rights reserved

Adding Router 2
192.168.2.5 192.168.1.5 PC1 eth0 eth0 PC3
NIC

PC2

eth0 ROUTER 1 ROUTER 2 eth0 eth1

192.168.1.6

eth0 192.168.1.1

eth1 192.168.2.1

CD3

CD1

CD2

some rights reserved

Configure Router 2's IP address


192.168.2.5 192.168.1.5 PC1 eth0 eth0 PC3
NIC

PC2

eth0 ROUTER 1 ROUTER 2 eth0 eth1 192.168.2.6 192.168.3.1

192.168.1.6

eth0 192.168.1.1

eth1 192.168.2.1

CD3

CD1

CD2

some rights reserved

Check Connectivity

Ping Router2/eth0(192.168.2.6) from PC1. What happens?

some rights reserved

Check Connectivity

Ping Router2/eth0(192.168.2.6) from PC1. What happens? Ping reaches 192.168.2.6, but cannot find its way back, since gateway of router 2 is not set

some rights reserved

Check Connectivity

Ping Router2/eth0(192.168.2.6) from PC1. What happens? Ping reaches 192.168.2.6, but cannot find its way back, since gateway of router 2 is not set
router2# route add default g$ 192 1!" 2 1

All interfaces are interlinked now


some rights reserved

Adding PC4
192.168.1.5 PC1 eth0
NIC

192.168.2.5 PC3

eth0

PC4 PC2 eth0 ROUTER 1 192.168.1.6 eth0 192.168.1.1 eth1 ROUTER 2 eth0 eth1 192.168.2.6 192.168.3.1

192.168.2.1

CD3

CD1

CD2

some rights reserved

Configure IP address of PC4


192.168.2.5 PC3 192.168.3.5 PC4 PC2 eth0 ROUTER 1 192.168.1.6 eth0 192.168.1.1 eth1 ROUTER 2 eth0 eth1 192.168.2.6 192.168.3.1 192.168.1.5 PC1 eth0 eth0
NIC

192.168.2.1

CD3

CD1

CD2

some rights reserved

Anything Special Here??!!


192.168.2.5 192.168.1.5 PC1 eth0 eth0
NIC

PC3 192.168.3.5 PC4

PC2

eth0 ROUTER 1 ROUTER 2 eth0 eth1 192.168.2.6 192.168.3.1

192.168.1.6

eth0 192.168.1.1

eth1

192.168.2.1

CD3

CD1

CD2

some rights reserved

Anything Special Here?!

Network is now symmetric, about CD2 Packets from one end of the network have to pass through two routers to reach the other end.

some rights reserved

Anything Tricky Here??!!


192.168.2.5 192.168.1.5 PC1 eth0 eth0
NIC

PC3 192.168.3.5 PC4

PC2

eth0 ROUTER 1 ROUTER 2 eth0 eth1 192.168.2.6 192.168.3.1

192.168.1.6

eth0 192.168.1.1

eth1

192.168.2.1

CD3

CD1

CD2

some rights reserved

Anything Tricky Here?!

Will pinging PC1 from PC4 work? (Assume default gateway of PC4 is set) Remember we successfully pinged Router2/eth0 from PC1.

some rights reserved

Anything Tricky Here?!

Will pinging PC1 from PC5 work? (Assume default gateway of PC5 is set) Remember we successfully pinged Router2/eth0 from PC1. Directly connected subnets, i.e. those connected to the same router are directly accessible. But if there is another router in between, the routing tables have to be properly configured. Router 1 doesn't know where to forward packets meant for 192.168.3.0/24

some rights reserved

Specific Routes
router1 # route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.6 dev eth1

The commands adds an entry in Router 1's routing table to forward all packets meant for 192.168.3.0/24, to 192.168.2.6 over eth1. Now pinging PC4 from PC1 works!

some rights reserved

Specific Routes

So far we specified only default routes for the routers. This is not enough, in a complicated network with multiple subnets and routers with more than two interfaces.

some rights reserved

Routes for Router 1


router1# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0 router1# route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 dev eth1 router1# route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.2.6 dev eth1

some rights reserved

Another Tricky Situation!

What happens when you ping PC3 from PC4?

some rights reserved

Another Tricky Situation!

What happens when you ping PC3 from PC4? Default GW of PC3 is 192.168.2.1 The reply will be forwarded to 192.168.2.1 and will never reach PC4(192.168.3.5)

some rights reserved

Another Tricky Situation!

What happens when you ping PC3 from PC4? Default GW of PC3 is 192.168.2.1 The reply will be forwarded to 192.168.2.1 and will never reach PC4(192.168.3.5) PC3 is connected to two routers and we need to specify the routes to be chosen for different destinations
some rights reserved

Routing Algorithms

Imagine how difficult it will be to set static routes for a large network? That's where Routing Algorithms come into play ZEBRA- a daemon for running routing algorithms on routers.

some rights reserved

Automating the network configuration

Setting up the machines so far was a lot of work! Imagine having to do it all over again!

some rights reserved

Netkit Labs

Make a directory for your lab Specify the network topology inside lab conf Specify boot dependency inside lab dep (At the console, type man lstart for details) Make empty directories for each VM Create .startup files for each machine and list the commands to be executed at startup. sabu@laptop$ lstart -d (director)*
some rights reserved

Only the Tip of the Iceberg!

You can try out lots of interesting stuff with Netkit


DHCP DNS Socket programing in Python RIP, OSPF, BGP and lots more...

some rights reserved

Attribution-Share Alike You are free: to Share to copy, distribute and transmit the work to Remix to adapt the work
For more details please visit http://creativecommons.org/licenses/by-sa/3.0/

some rights reserved

Das könnte Ihnen auch gefallen