add a make topology script
This commit is contained in:
parent
67d0131521
commit
4de1e3ad96
0
Blatt02/Blatt02.md
Normal file
0
Blatt02/Blatt02.md
Normal file
62
Blatt02/scripts/make_topo.sh
Normal file
62
Blatt02/scripts/make_topo.sh
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "reboot to erase the old configurations;"
|
||||||
|
bash ~/reboot.sh
|
||||||
|
echo "rebooting"
|
||||||
|
countdown=40
|
||||||
|
while [ $countdown -gt 0 ]; do
|
||||||
|
echo -ne "counting down: $countdown s \033[0K\r"
|
||||||
|
sleep 1
|
||||||
|
countdown=$((countdown - 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
assign_ip(){
|
||||||
|
local dev=$1
|
||||||
|
local eth_num=$2
|
||||||
|
local ip=$3
|
||||||
|
ssh $dev "ip link set dev eth$eth_num up"
|
||||||
|
ssh $dev "ip addr add $ip dev eth$eth_num"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "assigning IP on router1"
|
||||||
|
|
||||||
|
assign_ip "router1" 1 "10.5.1.2"
|
||||||
|
assign_ip "router1" 2 "10.5.3.3"
|
||||||
|
assign_ip "router1" 3 "10.5.4.2"
|
||||||
|
assign_ip "router1" 4 "10.5.2.3"
|
||||||
|
|
||||||
|
|
||||||
|
echo "assigning IP on router2"
|
||||||
|
|
||||||
|
assign_ip "router2" 1 "10.5.2.2"
|
||||||
|
assign_ip "router2" 2 "10.5.3.4"
|
||||||
|
assign_ip "router2" 3 "10.5.4.5"
|
||||||
|
assign_ip "router2" 4 "10.5.5.5"
|
||||||
|
|
||||||
|
|
||||||
|
echo "assigning IP on router3"
|
||||||
|
|
||||||
|
assign_ip "router3" 1 "10.5.3.2"
|
||||||
|
assign_ip "router3" 2 "10.5.4.3"
|
||||||
|
assign_ip "router3" 3 "10.5.4.4"
|
||||||
|
assign_ip "router3" 4 "10.5.5.2"
|
||||||
|
|
||||||
|
echo "assigning IP on router4"
|
||||||
|
|
||||||
|
assign_ip "router4" 1 "10.5.2.4"
|
||||||
|
assign_ip "router4" 2 "10.5.5.4"
|
||||||
|
assign_ip "router4" 3 "10.5.5.3"
|
||||||
|
|
||||||
|
echo "assigning IP on pc1"
|
||||||
|
|
||||||
|
assign_ip "pc1" 1 "10.5.1.1"
|
||||||
|
|
||||||
|
|
||||||
|
echo "assigning IP on pc2"
|
||||||
|
|
||||||
|
assign_ip "pc2" 1 "10.5.2.1"
|
||||||
|
|
||||||
|
echo "assigning IP on pc3"
|
||||||
|
|
||||||
|
assign_ip "pc3" 1 "10.5.3.1"
|
||||||
|
bash ~/checkip.sh
|
Loading…
Reference in New Issue
Block a user