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