Enter OSPF configuration mode
Enable OSPF on all interfaces which match the given IP address + "wildmask". A wildmask is used in access control lists to select a range of addresses. A "0" bit in the wildmask means the corresponding address bit must match, and a "1" means the corresponding address bit is "don't care". Examples:
network 213.172.133.17 0.0.0.0 area 0 network 213.172.133.98 0.0.0.0 area 0 -- talk OSPF only on those two interfaces network 213.172.133.0 0.0.0.255 area 0 -- talk OSPF on every interface we have whose IP address is 213.172.133.X network 0.0.0.0 255.255.255.255 area 0 -- talk OSPF on every interface we have
Note that it is important that we only talk OSPF to our own networks, never to customers or other ISPs (they could break our network by injecting bad information), so usually it is best just to list the interfaces we want to talk on.
Advertise all networks to which we are connected, including those which are not being used to talk to other OSPF routers.
("redistributed connected" by itself only distributes classful routes, i.e. whole class A/B/C networks, so it's important to add "subnets")
Advertise any static routes we have (except defaultroute).
Advertise a default route into OSPF, with a cost of "n". Typically this would go on your border router(s). Without 'always', the announcement will only be made if the router already has a valid defaultroute from somewhere else (e.g. a static route to a link which is up)
Use MD5 authentication on all OSPF packets
ip ospf cost <n> Set outbound interface cost ip ospf message-digest-key 1 md5 <string> Set MD5 authentication key
The initial network topology is the same as for the static routing exercise
t2-router1#reload ... t2-router1#show ip route The only routes you should see are (C)onnected routes for your own interfaces. If you have any (S)tatic routes, delete them like this: t2-router1#conf t t2-router1(config)#no ip route 213.172.133.96 255.255.255.240 213.172.133.17 ... t2-router1#write mem
(Your PC won't be able to ping any other PCs though, because your router doesn't have the routes any more)
t2-router1#conf t t2-router1(config)#router ospf 1 t2-router1(config-router)#network 213.172.133.17 0.0.0.0 area 0 t2-router1(config-router)#redistribute connected subnets t2-router1(config-router)#redistribute static subnets t2-router1(config-router)#area 0 authentication message-digest t2-router1(config-router)#int e0/0 (or int e0/1) t2-router1(config-if)#ip ospf message-digest-key 1 md5 t2@afnog t2-router1(config-if)#ip ospf cost 100 t2-router1(config-if)# [Hit ctrl-Z]
In real life you should use an MD5 key which is different to your login, enable and SNMP strings
You can also try an IOS 12.x feature which explicitly disables OSPF on all interfaces except those you nominate:
t2-router1(config)#router ospf 1 t2-router1(config-router)#passive-interface default t2-router1(config-router)#no passive-interface e0/0 (or e0/1)
t2-router1#show ip ospf int t2-router1#show ip ospf neighbor
To interpret the neighbor information:
2WAY = we are neighbors (we have established 2-way exchange of hellos), but neither of us is a designated router FULL = we are neighbors and we exchange routes (one of us is DR or BDR) DR = we are the Designated Router for this network BDR = we are the Backup Designated Router for this network DROTHER = we are neither DR nor BDR
If you see other states, they are intermediate steps on the way to establishing the final relationship, and should change after a few seconds.
DR = BDR =
t2-router1#show ip route
Routes learned through OSPF are tagged with O. Check that the next hop IP address for each route is correct
Also, the far router should also have picked up your route. You can go over to the other desk and ask to see "show ip route"
$ ping 213.172.133.142 ...
Don't type this - it goes on the class border router t2-border-1(config)#router ospf 1 t2-border-1(config-router)#default-information originate metric 100
This should be sufficient to establish connectivity to the outside Internet! Use ping, traceroute etc. to test this
t2-router1#write mem
/etc/resolv.conf
on
your PC
domain t2.ws.afnog.org nameserver 213.172.132.193 nameserver 213.172.132.60You should then be able to ssh/telnet to the outside world.
A loopback interface is a single (/32) IP address which belongs to a device, independent of its physical interface addresses. It's very convenient when managing routers, because you can use the loopback address as a fixed address to telnet to, or monitor using SNMP, which will continue to work even if one or more of the interfaces has failed.
t2-router1#conf t t2-router1(config)#int loopback0 t2-router1(config-if)#ip address 213.172.133.48 255.255.255.255 t2-router1(config-if)# [Hit ctrl-Z]
For safety, at this point you will also store a copy of your router configuration on your Unix PC.
# vi /etc/hosts.allow Add the following lines at or near the top: use your router's IP address tftpd : 213.172.133.6 : allow tftpd : ALL : deny Exit and save # vi /etc/inetd.conf Find the line for tftp. Uncomment it, by removing the # at the front Exit and save # killall -1 inetd # mkdir /tftpboot # touch /tftpboot/t2-config # chmod 666 /tftpboot/t2-config
(Note that the tftp daemon requires a file to already exist, and be publicly writable, before it will allow writes)
t2-router1#copy running-config tftp Address or name of remote host? 213.172.133.97 Destination filename [running-config]? t2-config !! 774 bytes copied in 2.836 seconds (387 bytes/sec) t2-router1#
$ less /tftpboot/t2-config(To return to a saved configuration: do "copy tftp startup-config" to download it into flash, then "reload" to reboot the router).
Above you showed how OSPF can learn routes from the rest of your network, without having to manually insert static routes. Now you can show how OSPF can adapt to topology changes and choose better (lower cost) routes when they are available
t2-router1#conf t t2-router1(config)#int s0/0 (or int s0/1) t2-router1(config-if)#description Serial link to desk B t2-router1(config-if)#encap ppp t2-router1(config-if)#ip address 213.172.133.193 255.255.255.252 t2-router1(config-if)#no shutdown
Once this is done on both routers, "show int s0" should show that the Interface is up (layer 1), but Line protocol is down (layer 2).
t2-router1(config-if)#clock rate 64000
This is only because this is a back-to-back cable; normally you would use synchronous modems which generate clock
t2-router1#ping 213.172.133.194
t2-router1#conf t t2-router1(config)#router ospf 1 t2-router1(config-router)#network 213.172.133.193 0.0.0.0 area 0 t2-router1(config-router)#no passive-interface s0/0 (or s0/1) t2-router1(config-router)#int s0/0 (or s0/1) t2-router1(config-if)#ip ospf message-digest-key 1 md5 t2@afnog t2-router1(config-if)#ip ospf cost 500 t2-router1(config-if)# [Hit ctrl-Z]
t2-router1#show ip route
Look carefully at the route to your neighbor's desk network, and your neighbor's router loopback interface, and make a note of it.
Does the desk which had its ethernet unplugged still have connectivity to the Internet? When you traceroute, what route do the packets take?
Look at the routes again. What has happened to the route to your neighbor's desk network, and to their loopback interface?
Check the forwarding table ("show ip route"). Now what do you notice about the route to your neighboring desk's network?