Agenda: exercises-rancid.txt

File exercises-rancid.txt, 4.7 KB (added by admin, 9 years ago)
Line 
1Advanced Registry Operations Curriculum
2Using RANCID
3
4Notes:
5------
6* Commands preceded with "$" imply that you should execute the command as
7  a general user - not as root.
8* Commands preceded with "#" imply that you should be working as root.
9* Commands with more specific command lines (e.g. "RTR-GW>" or "mysql>")
10  imply that you are executing commands on remote equipment, or within
11  another program.
12
13Exercises
14---------
15
160. Log in to your PC or open a terminal window as the tladmain user.
17
181. Verify that postfix (mail system) is installed and running.
19
20        $ ps ax | grep postfix
21
222. Add an alias for the rancid user in /etc/aliases file
23
24        $ sudo vi /etc/aliases
25
26        rancid-all:             sysadmin
27        rancid-admin-all:       sysadmin
28
29        Save the file, then run:
30
31        $ sudo newaliases
32
333. Install Rancid itself
34
35    $ sudo apt-get install rancid-core
36
37        (Say yes to the questions)
38
39    $ sudo apt-get install rancid-util
40    $ sudo apt-get install rancid-cgi
41    $ sudo apt-get install cvsweb
42    $ sudo apt-get install cvs
43
44    Or you could install everything at once:
45   
46    $ sudo apt-get install rancid-util rancid-cgi cvsweb cvs
47
484. Edit /etc/rancid/rancid.conf
49
50        $ sudo vi /etc/rancid/rancid.conf
51
52        Find the line with the parameter LIST_OF_GROUPS, and replace it with
53
54        LIST_OF_GROUPS="all"
55
565. Choose which router you will manage:
57
58        pc1 -  pc9              192.168.5.129
59        pc10 - pc18             192.168.5.161
60
61
626. Change to the rancid user
63
64        - First you need to become the root user:
65
66        $ su -
67       
68          Now you can become the RANCID user:
69       
70        # su -s /bin/bash rancid
71       
72        - Check that you ARE the rancid user:
73
74        $ id
75
76        - You should see something similar (numbers may be different):
77
78        uid=114(rancid) gid=124(rancid) groups=124(rancid)
79
807. Create /var/lib/rancid/.cloginrc
81
82        R vi /var/lib/rancid/.cloginrc
83
84        add user 192.168.5.xxx admin
85        add password 192.168.5.xxx GTcctld! GTcctld!
86
87        (Remember to replace xxx with .129 for group 1, or .161 for group 2)
88
89        $ chmod 600 /var/lib/rancid/.cloginrc
90
917. Initialize the CVS repository for rancid:
92
93        $ /usr/lib/rancid/bin/rancid-cvs
94
95        - You should see something similar to this:
96
97No conflicts created by this import
98
99cvs checkout: Updating all
100Directory /var/lib/rancid/CVS/all/configs added to the repository
101cvs commit: Examining configs
102cvs add: scheduling file `router.db' for addition
103cvs add: use `cvs commit' to add this file permanently
104/var/lib/rancid/CVS/all/router.db,v  <--  router.db
105initial revision: 1.1
106
107
1088. Test login to the router
109
110        $  /usr/lib/rancid/bin/clogin 192.168.5.xxx
111
112        (where xxx is the IP of the router (either .129 or .161))
113
114        - You should now be logged in to the router, and see something like:
115
116        pcx-pcy-gw#
117
118        - Type 'exit' to logout
119
1209. Add the router.db
121
122        $ vi /var/lib/rancid/all/router.db
123
124        Add:
125
126        192.168.5.xxx:cisco:up
127
128        (remember to replace xxx with .129 or .161)
129
13010. Let's run rancid!
131
132        $ /usr/lib/rancid/bin/rancid-run
133
134        (Should take a few seconds)
135
13611. Check out the logs:
137
138        $ cd /var/lib/rancid/logs
139        $ ls -l
140
141        ... View the contents of the file:
142
143        $ more all.*
144
145
14612. Look at the configs
147
148        $ cd /var/lib/rancid/all/configs
149        $ more 192.168.5.xxx
150
151        - If all went well, you can see the config of the router.
152
153
15413. Let's change an interface Description on the router
155
156        $ /usr/lib/rancid/bin/clogin 192.168.5.xxx
157
158        - At the "pcx-pcy-gw>" prompt, enter the command:
159
160        config terminal
161
162        - You should see:
163
164Enter configuration commands, one per line.  End with CNTL/Z.
165pcx-pcy-gw(config)#
166
167        - Enter:
168
169        interface Ethernet0/0
170
171        - You should get this prompt:
172
173pcx-pcy-gw(config-if)#
174
175        - Enter:
176
177        pcx-pcy-gw(config-if)> description Internal Interface for 192.168.5.xxx/27
178
179
180        - Then type CTRL-Z (press Control + the Z key)
181
182        - You should now have this prompt:
183
184pcx-pxy-gw>
185
186        - To save the config to memory:
187
188        write memory
189
190        - You should see:
191
192Building configuration...
193[OK]
194
195        - To exit type:
196
197        exit
198
19914. Let's run rancid again:
200
201        $ /usr/lib/rancid/bin/rancid-run
202
203        Look at the config and logs
204
205        $ ls /var/lib/rancid/logs/
206
20715. Let's see the differences
208
209        $ cd /var/lib/rancid/all/configs
210        $ ls -l
211
212        You should see all the router config files
213
214        $ cvs log 192.168.5.xxx
215
216        (where xxx is the IP of your router, .129 or .161)
217
218        Notice the revisions.  Let's view the difference between two versions:
219
220        $ cvs diff -r 1.2 -r 1.3 192.168.5.xxx | more
221
222        ... can you find your changes ?
223
22416. Check your mail
225
226        As the user "sysadmin", run the "mutt" mailer to see the mails that
227        Rancid has sent:
228
229        $ exit
230        # su - sysadmin
231
232        $ mutt
233
234        If everything goes as planned, you should be able to read the mails
235        sent by Rancid.
236
237        (use q or x to quit mutt)
238
23917. Finally, let's make rancid run automatically every 30 minutes from cron
240
241        $ crontab -e
242
243        - Add this line:
244
245        */30  *  *  *  *  /usr/lib/rancid/bin/rancid-run
246
247        ... then save and quit
248