Every language has its dark feature, something only for the use of wizards. In Cisco IOS that feature is the "redistribute" command. If you are a mere mortal rather than a routing god, then using "redistribute" in your configuration is a sign that you're about to make a serious mistake.
"Redistribute" copies routes from one routing process to another. You often see it used like this:
! Do not code like this... router ospf 65000 ! Copy all static routes into this process redistribute static
The really dangerous usage looks like this:
! Do not code like this... router ospf 65000 ! Copy all routes from the BGP process, a fool's way of getting ! a BGP-leaned default route into OSPF. redistribute bgp 65000
Add a few more routers and you get self-sustaining, flapping routes. Routes that don't indicate reachability. Whoops.
Whenever you use "redistribute" replace it with a "network" statement. If you were redistributing to inject a default route, then replace it with a "default-information" statement.
People resist this advice, because it replaces the "redistribute" one-liner with one "network" command per route. Suck it up, long and correct beats short and wrong.
! Do it this way interface ethernet 0 ip address 10.1.1.255 255.255.255.0 interface ethernet 1 ip address 10.1.2.255 255.255.255.0 interface ethernet 2 ip address 10.1.3.255 255.255.255.0 router ospf 65000 network 10.1.1.255 0.0.0.255 route-map OSPF-NETWORK-ROUTE network 10.1.2.255 0.0.0.255 route-map OSPF-NETWORK-ROUTE network 10.1.3.255 0.0.0.255 route-map OSPF-NETWORK-ROUTE default-information originate route-map OSPF-DEFAULT-ROUTE
Note that each "network" line exactly matches a route. A beginner's error is to have the "network" statement match your entire IP allocation. That appears to work, but fails when the network topology gets complex (ie, just when you've got a huge handful of routers which need to be reconfigured).
Another beginner's error is to list routes which are not originated from this router. You don't need to list another router's routes. Those are learned via the routing protocol.
The route-maps apply attributes to the route. For the OSPF routes the interesting attribute is the 32-bit tag. That can be usefully set to the site in which the route originates.
For BGP routes the interesting attributes are the MED and the community values. Set the MED to the number of deciseconds of delay on the link (from "ping"). Set communities to indicate the originating router and the originating site, plus anything else which you might need in your routing policy (such as if the route was learned from a financially costly link).
The conditions for a route advertisment when using this technique are important to know. A route is advertised by our process "ospf 65000" iff there is a "network" statement and the prefix in the statement exactly matches a prefix in the *forwarding* table. The gating of all routes through matches in the forwarding table is what prevents routing loops, as no route will be advertised that isn't actually in use. The "redistribute" command does not look into the fowarding table at all.
Similarly, "default-information originate" looks for a 0.0.0.0/0 route in the forwarding table before adding 0.0.0.0/0 to the routing process.
You often need to have a route for your entire IP allocation. Inject that route like this:
! Do it this way ip route 10.1.0.0 0.0.255.255 254 router bgp 65000 network 10.1.0.0 mask 255.255.0.0 route-map BGP-ORIGINATE-ROUTE
The administrative distance of 254 indicates that this route will lose should there be a matching route learned from any other routing process. It is the worst sort of magic number, in that it's not magic at all. It's actually avoiding 255, which is a magic number.