Commit 21d7d48b authored by adietmue's avatar adietmue
Browse files

Exercise week 7.

parent c6745b48
{
"ltex.workspaceFolderDictionary": {
"en-US": [
"CommNet",
"eBGP",
"iBGP",
"LDP",
"loopback"
]
}
}
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
if [ $# -lt 1 ]; then
echo $0: usage: access_cli.sh device_name [command]
exit 1
fi
case $1 in
"R1")
DEV=1_R1router
CMD=vtysh
;;
"R2")
DEV=1_R2router
CMD=vtysh
;;
"R3")
DEV=1_R3router
CMD=vtysh
;;
"R4")
DEV=1_R4router
CMD=vtysh
;;
"CENT1")
DEV=20_CENT1router
CMD=vtysh
;;
"CENT2")
DEV=20_CENT2router
CMD=vtysh
;;
"S1")
DEV=30_S1router
CMD=vtysh
;;
"OERL-host")
DEV=1_L2_CS1_oerl_host
CMD=bash
;;
"BAHN-host")
DEV=1_L2_UBS2_bahn_host
CMD=bash
;;
"PARA-host")
DEV=1_L2_CS2_para_host
CMD=bash
;;
"BELLE-host")
DEV=1_L2_UBS1_belle_host
CMD=bash
;;
"CENT1-host")
DEV=20_CENT1host
CMD=bash
;;
"CENT2-host")
DEV=20_CENT2host
CMD=bash
;;
"S1-host")
DEV=30_S1host
CMD=bash
;;
*)
echo "Unknown device name. The available devices are the following:
R1 R2 R3 R4 CENT1 CENT2 S1 OERL-host BAHN-host PARA-host BELLE-host CENT1-host CENT2-host S1-host"
exit 1
;;
esac
if [ $# -lt 2 ]; then
# Use default command
sudo docker exec -it $DEV $CMD
exit 0
fi
# Use provided command instead
sudo docker exec -it $DEV ${@: 2}
# Building the mini-Internet
This folder contains scripts to get the mini-Internet up and running.
If you are curious, check out the scripts to find out what they are doing!
Concretely, we have:
- `topo/`: The configuration for the mini-Internet platform, e.g. which devices to use, and how to connect them.
- `default_config/`: The initial commands to send to each device to set up the interfaces and addresses for this exercise.
- `./build.sh` and `./cleanup.sh`: Scripts to easily create/tear down the mini-Internet.
#!/bin/bash
# Get the current script directory, no matter where we are called from.
# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
cur_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
platform_dir=$HOME/mini_internet_project/platform/
# Pull the latest version of the platform
echo "Pull the mini-Internet repository"
git -C $platform_dir pull
# Building the topology
echo "Copy the configuration files"
cp -r $cur_dir/topo/* $platform_dir/config/
echo "Clean-up the mini-Internet currently running (if any)"
(cd $platform_dir; sudo $platform_dir/cleanup/hard_reset.sh)
echo "Run the new mini-Internet"
(cd $platform_dir; sudo $platform_dir/startup.sh)
# Run the default configuration
for c in \
1_R1router:R1.sh \
1_R2router:R2.sh \
1_R3router:R3.sh \
1_R4router:R4.sh \
1_R5router:R5.sh \
20_CENT1router:CENT1.sh \
20_CENT2router:CENT2.sh \
30_S1router:S1.sh \
20_CENT1host:CENT1-host.sh \
20_CENT2host:CENT2-host.sh \
30_S1host:S1-host.sh \
1_L2_UBS1_belle_host:BELLE-host.sh \
1_L2_UBS2_bahn_host:BAHN-host.sh \
1_L2_CS1_oerl_host:OERL-host.sh \
1_L2_CS2_para_host:PARA-host.sh \
1_R5host:R5-host.sh
do
cname=$(echo $c | cut -f 1 -d ':')
cscript=$(echo $c | cut -f 2 -d ':')
echo "Configuring $cname using $cscript..."
sudo docker cp $cur_dir/default_config/$cscript $cname:/home/
sudo docker exec -it $cname chmod 755 /home/$cscript
sudo docker exec -it $cname /home/$cscript
done
#!/bin/bash
cur_dir=$(pwd)
platform_dir=$HOME/mini_internet_project/platform/
cd $platform_dir
echo "Clean-up the mini-Internet currently running (if any)"
sudo $platform_dir/cleanup/hard_reset.sh
#!/bin/bash
ip address add 10.1.0.1/16 dev 1-BAHN
ip route add default via 10.1.0.2
#!/bin/bash
ip address add 10.0.0.1/16 dev 1-BELLE
ip route add default via 10.0.0.2
#!/bin/bash
ip address add 10.1.0.1/24 dev CENT1router
ip route add default via 10.1.0.2
#!/bin/bash
vtysh << EOM
conf t
interface lo
ip address 20.151.0.1/24
exit
router ospf
ospf router-id 20.151.0.1
network 20.151.0.1/24 area 0
exit
interface port_CENT2
ip address 20.0.0.1/24
ip ospf cost 1
exit
router ospf
network 20.0.0.1/24 area 0
exit
interface host
ip address 10.1.0.2/24
exit
router ospf
network 10.1.0.2/24 area 0
exit
router bgp 20
neighbor 20.152.0.1 remote-as 20
neighbor 20.152.0.1 update-source lo
address-family ipv4 unicast
network 20.0.0.0/8
neighbor 20.152.0.1 next-hop-self
exit
exit
ip route 20.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip address add 192.168.0.1/24 dev CENT2router
ip route add default via 192.168.0.2
#!/bin/bash
vtysh << EOM
conf t
interface lo
ip address 20.152.0.1/24
exit
router ospf
ospf router-id 20.152.0.1
network 20.152.0.1/24 area 0
exit
interface port_CENT1
ip address 20.0.0.2/24
ip ospf cost 1
exit
router ospf
network 20.0.0.2/24 area 0
exit
interface host
ip address 192.168.0.2/24
exit
router ospf
network 192.168.0.2/24 area 0
exit
router bgp 20
neighbor 20.151.0.1 remote-as 20
neighbor 20.151.0.1 update-source lo
address-family ipv4 unicast
network 20.0.0.0/8
neighbor 20.151.0.1 next-hop-self
exit
exit
ip route 20.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip address add 192.168.1.1/24 dev 1-OERL
ip route add default via 192.168.1.2
#!/bin/bash
ip address add 10.1.1.1/24 dev 1-PARA
ip route add default via 10.1.1.2
#!/bin/bash
ip link add VRF_CS type vrf table 10
ip link set dev VRF_CS up
ip link set ext_20_CENT1 master VRF_CS
ip link add VRF_UBS type vrf table 20
ip link set dev VRF_UBS up
ip link set R1-L2 master VRF_UBS
vtysh << EOM
conf t
interface lo
ip address 1.151.0.1/32
exit
router ospf
ospf router-id 1.151.0.1
network 1.151.0.1/32 area 0
exit
interface port_R2
ip address 1.0.0.1/24
ip ospf cost 100
exit
router ospf
network 1.0.0.1/24 area 0
exit
interface port_R3
ip address 1.0.1.1/24
ip ospf cost 1
exit
router ospf
network 1.0.1.1/24 area 0
exit
interface port_R5
ip address 1.0.2.1/24
ip ospf cost 1
exit
router ospf
network 1.0.2.1/24 area 0
exit
interface R1-L2
ip address 10.0.0.2/16
ip ospf cost 1
exit
ip route 1.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip link add VRF_CS type vrf table 10
ip link set dev VRF_CS up
ip link set R2-L2 master VRF_CS
vtysh << EOM
conf t
interface lo
ip address 1.152.0.1/32
exit
router ospf
ospf router-id 1.152.0.1
network 1.152.0.1/32 area 0
exit
interface port_R1
ip address 1.0.0.2/24
ip ospf cost 100
exit
router ospf
network 1.0.0.2/24 area 0
exit
interface port_R4
ip address 1.0.4.1/24
ip ospf cost 1
exit
router ospf
network 1.0.4.1/24 area 0
exit
interface port_R5
ip address 1.0.3.1/24
ip ospf cost 1
exit
router ospf
network 1.0.3.1/24 area 0
exit
interface R2-L2
ip address 192.168.1.2/24
exit
ip route 1.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip link add VRF_CS type vrf table 10
ip link set dev VRF_CS up
ip link set R3-L2 master VRF_CS
vtysh << EOM
conf t
interface lo
ip address 1.153.0.1/32
exit
router ospf
ospf router-id 1.153.0.1
network 1.153.0.1/32 area 0
exit
interface port_R1
ip address 1.0.1.2/24
ip ospf cost 1
exit
router ospf
network 1.0.1.2/24 area 0
exit
interface port_R4
ip address 1.0.6.1/24
ip ospf cost 100
exit
router ospf
network 1.0.6.1/24 area 0
exit
interface port_R5
ip address 1.0.5.1/24
ip ospf cost 100
exit
router ospf
network 1.0.5.1/24 area 0
exit
interface R3-L2
ip address 10.1.1.2/24
exit
ip route 1.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip link add VRF_UBS type vrf table 20
ip link set dev VRF_UBS up
ip link set R4-L2 master VRF_UBS
vtysh << EOM
conf t
interface lo
ip address 1.154.0.1/32
exit
router ospf
ospf router-id 1.154.0.1
network 1.154.0.1/32 area 0
exit
interface port_R2
ip address 1.0.4.2/24
ip ospf cost 1
exit
router ospf
network 1.0.4.2/24 area 0
exit
interface port_R3
ip address 1.0.6.2/24
ip ospf cost 100
exit
router ospf
network 1.0.6.2/24 area 0
exit
interface port_R5
ip address 1.0.7.2/24
ip ospf cost 1
exit
router ospf
network 1.0.7.2/24 area 0
exit
interface R4-L2
ip address 10.1.0.2/16
exit
interface ext_30_S1
ip address 179.0.1.1/24
exit
ip route 1.0.0.0/8 Null0
exit
EOM
#!/bin/bash
ip address add 1.105.0.1/24 dev R5router
ip route add default via 1.105.0.2
#!/bin/bash
vtysh << EOM
conf t
interface lo
ip address 1.155.0.1/32
exit
router ospf
ospf router-id 1.155.0.1
network 1.155.0.1/32 area 0
exit
interface host
ip address 1.105.0.2/24
ip ospf cost 1
exit
router ospf
network 1.105.0.2/24 area 0
exit
interface port_R1
ip address 1.0.2.2/24
ip ospf cost 1
exit
router ospf
network 1.0.2.2/24 area 0
exit
interface port_R2
ip address 1.0.3.2/24
ip ospf cost 1
exit
router ospf
network 1.0.3.2/24 area 0
exit
interface port_R3
ip address 1.0.5.2/24
ip ospf cost 100
exit
router ospf
network 1.0.6.2/24 area 0
exit
interface port_R4
ip address 1.0.7.1/24
ip ospf cost 1
exit
router ospf
network 1.0.7.1/24 area 0
exit
exit
EOM
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment