1 | Using RANCID! |
---|
2 | |
---|
3 | Network management & monitoring Workshop |
---|
4 | |
---|
5 | how to configure it: |
---|
6 | |
---|
7 | 1. Start by installing the postfix mail system + mail client |
---|
8 | |
---|
9 | # apt-get install postfix |
---|
10 | # apt-get install mutt |
---|
11 | |
---|
12 | (answer "Internet Site" at the question of which type of host you are |
---|
13 | running) |
---|
14 | |
---|
15 | 2. Add an alias for the rancid user in /etc/aliases |
---|
16 | |
---|
17 | rancid-all: mgmt |
---|
18 | rancid-admin-all: mgmt |
---|
19 | |
---|
20 | Save the file, then run: |
---|
21 | |
---|
22 | # newaliases |
---|
23 | |
---|
24 | 3. Install Rancid itself |
---|
25 | |
---|
26 | apt-get install rancid-core |
---|
27 | |
---|
28 | (just say yes to the questions) |
---|
29 | |
---|
30 | apt-get install rancid-util |
---|
31 | apt-get install rancid-cgi |
---|
32 | apt-get install cvsweb |
---|
33 | apt-get install cvs |
---|
34 | |
---|
35 | 4. Edit /etc/rancid/rancid.conf |
---|
36 | |
---|
37 | Find the line with the parameter LIST_OF_GROUPS, and replace it with |
---|
38 | |
---|
39 | LIST_OF_GROUPS="all" |
---|
40 | |
---|
41 | 5. Choose which router you will manage: |
---|
42 | |
---|
43 | pc1 + pc2 169.223.142.11 |
---|
44 | pc3 + pc4 169.223.142.12 |
---|
45 | pc5 + pc6 169.223.142.13 |
---|
46 | pc7 + pc8 169.223.142.14 |
---|
47 | pc9 + pc10 169.223.142.15 |
---|
48 | pc11 + pc12 169.223.142.16 |
---|
49 | pc13 + pc14 169.223.142.17 |
---|
50 | pc15 169.223.142.18 |
---|
51 | |
---|
52 | 6. Change to the rancid user |
---|
53 | |
---|
54 | # su -s /bin/bash rancid |
---|
55 | |
---|
56 | - Check that you ARE the rancid user: |
---|
57 | |
---|
58 | > id |
---|
59 | |
---|
60 | - You should see something similar: |
---|
61 | |
---|
62 | uid=115(rancid) gid=123(rancid) groups=123(rancid) |
---|
63 | |
---|
64 | 7. Create /var/lib/rancid/.cloginrc |
---|
65 | |
---|
66 | > vi /var/lib/rancid/.cloginrc |
---|
67 | |
---|
68 | add user 169.223.142.x admin |
---|
69 | add password 169.223.142.x apr10cot apr10cot |
---|
70 | |
---|
71 | (Remember to replace x with .11 - .18) |
---|
72 | |
---|
73 | > chmod 600 /var/lib/rancid/.cloginrc |
---|
74 | |
---|
75 | 7. Initialize the CVS repository for rancid: |
---|
76 | |
---|
77 | > /usr/lib/rancid/bin/rancid-cvs |
---|
78 | |
---|
79 | - You should see something similar to this: |
---|
80 | |
---|
81 | No conflicts created by this import |
---|
82 | |
---|
83 | cvs checkout: Updating all |
---|
84 | Directory /var/lib/rancid/CVS/all/configs added to the repository |
---|
85 | cvs commit: Examining configs |
---|
86 | cvs add: scheduling file `router.db' for addition |
---|
87 | cvs add: use `cvs commit' to add this file permanently |
---|
88 | /var/lib/rancid/CVS/all/router.db,v <-- router.db |
---|
89 | initial revision: 1.1 |
---|
90 | |
---|
91 | |
---|
92 | 8. Test login to the router |
---|
93 | |
---|
94 | > /usr/lib/rancid/bin/clogin 169.223.142.x |
---|
95 | |
---|
96 | (where x is the IP of the route (from .11 - .18)) |
---|
97 | |
---|
98 | - You should now be logged in to the router, and see something like: |
---|
99 | |
---|
100 | rtrX# |
---|
101 | |
---|
102 | - Type 'exit' to logout |
---|
103 | |
---|
104 | 9. Add the router.db |
---|
105 | |
---|
106 | > vi /var/lib/rancid/all/router.db |
---|
107 | |
---|
108 | Add: |
---|
109 | |
---|
110 | 169.223.142.x:cisco:up |
---|
111 | |
---|
112 | (remember to replace x with .11 - .18) |
---|
113 | |
---|
114 | 10. Let's run rancid! |
---|
115 | |
---|
116 | > /usr/lib/rancid/bin/rancid-run |
---|
117 | |
---|
118 | (Should take a few seconds) |
---|
119 | |
---|
120 | 11. Check out the logs: |
---|
121 | |
---|
122 | > cd /var/lib/rancid/logs |
---|
123 | > ls -l |
---|
124 | |
---|
125 | ... View the contents of the file: |
---|
126 | |
---|
127 | > more all.* |
---|
128 | |
---|
129 | |
---|
130 | 12. Look at the configs |
---|
131 | |
---|
132 | > cd /var/lib/rancid/all/configs |
---|
133 | > more 169.223.142.x |
---|
134 | |
---|
135 | - If all went well, you can see the config of the router. |
---|
136 | |
---|
137 | |
---|
138 | 13. Let's change an interface Description on the router |
---|
139 | |
---|
140 | > /usr/lib/rancid/bin/clogin 169.223.142.x |
---|
141 | |
---|
142 | - At the "rtrX#" prompt, enter the command: |
---|
143 | |
---|
144 | config terminal |
---|
145 | |
---|
146 | - You should see: |
---|
147 | |
---|
148 | Enter configuration commands, one per line. End with CNTL/Z. |
---|
149 | rtrX(config)# |
---|
150 | |
---|
151 | - Enter: |
---|
152 | |
---|
153 | interface FastEthernet 0/0 |
---|
154 | |
---|
155 | - You should get this prompt: |
---|
156 | |
---|
157 | rtrX(config-if)# |
---|
158 | |
---|
159 | - Enter: |
---|
160 | |
---|
161 | description testing rancid from PCX # X = the number of your PC |
---|
162 | |
---|
163 | |
---|
164 | - Then type CTRL-Z (press Control + the Z key) |
---|
165 | |
---|
166 | - You should now have this prompt: |
---|
167 | |
---|
168 | rtrx# |
---|
169 | |
---|
170 | - To save the config to memory: |
---|
171 | |
---|
172 | write memory |
---|
173 | |
---|
174 | - You should see: |
---|
175 | |
---|
176 | Building configuration... |
---|
177 | [OK] |
---|
178 | |
---|
179 | - If you are running on a virtual router (.11 - .18), run this as well: |
---|
180 | |
---|
181 | copy running-config flash:running-config |
---|
182 | |
---|
183 | (press enter at every prompt) |
---|
184 | |
---|
185 | - Type to exit: |
---|
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 169.223.142.x |
---|
205 | |
---|
206 | (where X is the IP of the router, .11 - .18) |
---|
207 | |
---|
208 | Notice the revisions. Let's view the difference between two versions: |
---|
209 | |
---|
210 | > cvs diff -r 1.2 -r 1.3 169.223.142.x | more |
---|
211 | |
---|
212 | ... can you find your changes ? |
---|
213 | |
---|
214 | 16. Check your mail |
---|
215 | |
---|
216 | As the user "mgmt", run the "mutt" mailer to see the mails that |
---|
217 | Rancid has sent: |
---|
218 | |
---|
219 | > exit |
---|
220 | # su mgmt |
---|
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 | |
---|