For example, if a router has networks 10.0.10.0/24 and 10.0.20.0/24,
we can choose to advertise only 10.0.10.0/24 by typing network
10.0.10.0 0.0.0.255. This way other routers will learn 10.0.10.0/24 but not 10.0.20.0/24.
No, you are confused about the
network statement. In OSPF, RIPv2, and EIGRP, the network statement tells the routing process which interfaces it should include in the routing process, not what networks to advertise. The routing process will get the actual networks to advertise from the interfaces included in the routing process.
For example, if there is an interface with the address of
10.0.10.1 255.255.255.192, and you have an OSPF network statement of
network 10.0.10.0 0.0.0.255, OSPF will only advertise
RIPv2 can advertise non-classful networks if you use the
no auto-summary command under the RIP configuration. If there are other interfaces that are included in the classful range, you can filter those in other ways, such as a distribute list, and you can make those interfaces passive with the
passive-interface command. Given the same scenario as explained above with OSPF, using RIPv2 with
no auto-summary and
network 10.0.10.0, RIPv2 will also advertise the
For example, if
10.0.10.0/24 is on an interface, and you have other interfaces with networks in the
10.0.0.0/8 classful network, you could use a distribute list to only permit the
10.0.10.0/24 network. Something like:
access-list 1 permit 10.0.10.0 0.255.255.255 ! remember the implicit deny all at the end of an access list
distribute-list 1 out <outbound advertising interface>
BGP, on the other hand, does use the network statement to advertise the network, but only if that exact network already exists in the routing table. For example, if
10.0.10.0/26 is in the routing table, for BGP,
network 10.0.10.0 mask 255.255.255.192 will advertise the network, but
network 10.0.10.0 mask 255.255.255.0 will not advertise a network.
In general, the IGP network statements tell the IGP which interfaces to include in the routing process, but BGP uses the network statement to determine which networks that exist in the routing table to advertise.