-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2.sh
155 lines (144 loc) · 4.74 KB
/
lab2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
#
# This script was created to demonstrate how interact with a micro network topology using
# User Mode Linux to create other GNU/Linux machines and configure them as a
# LAN environment.
#
# created by:Franzvitor Fiorim
# date: September 10, 2017
# updated: October 16, 2020
# Before execute this script
#
# Before execute this script you will need to execute the net.sh script that
# is locate in ../utils diretory
#
# Logic topology
#
# [UML-A1] [UML-A2] [UML-B1] [UML-B2]
# | | | |
# |___________| |__________|
# | |
# | |
# | |
# [Router A]--------[Router D]------------[Router B]
# |
# |
# |
# [Router C]
# |
# |
# |
# [ HOST ]
#
echo
echo '#-------------------[ Starting user: ((( '$USER' ))) ]-------------------#'
echo
## killall zumbi process
echo '# Cleaning zumbi process...'
sudo killall kernel64-4.3.5 < /dev/null > /dev/null
sudo killall uml_switch < /dev/null > /dev/null
sudo fuser -k /var/run/uml-utilities/uml_switch.ctl < /dev/null > /dev/null
#sudo tunctl -d tap0
echo '[OK]'
echo
echo '# Checking TAP interface ... '
echo
echo 'tap0'
sudo ifconfig tap0 | grep -w inet | awk {'print $2'} # Print IP address
sudo ifconfig tap0 | grep -w inet | awk {'print $4'} # Print netmask
echo
echo '[OK]'
echo
# Creating a swap file
#dd if=/dev/zero of=../emptyfs.swap bs=1024 seek=$[ 1024 * 1024 ] count=1
# Creating the switches
echo
echo 'Creating Switchs ...'
uml_switch -unix ./switch-tap -tap tap0 < /dev/null > /dev/null &
uml_switch -unix ./switch-RC_RD < /dev/null > /dev/null &
uml_switch -unix ./switch-RD_RA < /dev/null > /dev/null &
uml_switch -unix ./switch-RD_RB < /dev/null > /dev/null &
uml_switch -unix ./switch-RA_uml-A1-A2 < /dev/null > /dev/null &
uml_switch -unix ./switch-RB_uml-B1-B2 < /dev/null > /dev/null &
echo '[ok]'
# Starting UML`s in multi-tab mode ...
echo '# Starting UMLs ...'
gnome-terminal --tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:cc:01,unix,./switch-tap \
eth1=daemon,cc:00:ff:ee:cc:02,unix,./switch-RC_RD \
umid=RC \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./RC.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-RC.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:dd:01,unix,./switch-RC_RD \
eth1=daemon,cc:00:ff:ee:dd:02,unix,./switch-RD_RA \
eth2=daemon,cc:00:ff:ee:dd:03,unix,./switch-RD_RB \
umid=RD \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./RD.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-RD.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:aa:01,unix,./switch-RD_RA \
eth1=daemon,cc:00:ff:ee:aa:02,unix,./switch-RA_uml-A1-A2 \
umid=RA \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./RA.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-RA.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:bb:01,unix,./switch-RD_RB \
eth1=daemon,cc:00:ff:ee:bb:02,unix,./switch-RB_uml-B1-B2 \
umid=RB \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./RB.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-RB.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:aa:03,unix,./switch-RA_uml-A1-A2 \
umid=uml-A1 \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./uml-A1.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-uml-A1.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:aa:04,unix,./switch-RA_uml-A1-A2 \
umid=uml-A2 \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./uml-A2.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-uml-A2.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:bb:03,unix,./switch-RB_uml-B1-B2 \
umid=uml-B1 \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./uml-B1.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-uml-B1.cow,../emptyfs.swap > /dev/null" \
--tab-with-profile=default \
--command "../utils/kernel64-4.3.5 \
mode=skas0 \
eth0=daemon,cc:00:ff:ee:bb:04,unix,./switch-RB_uml-B1-B2 \
umid=uml-B2 \
mem=128M \
xterm=gnome-terminal,-t,-x con=null con0=fd:0,fd:1 \
ubd0=./uml-B2.cow,../utils/CentOS6.x-AMD64-root_fs \
ubd1=./swap32-uml-B2.cow,../emptyfs.swap > /dev/null" \ &
echo '[OK]'
echo