If you use VLANs, then you need to configure an IP address for each of the router interfaces, so that clients in each subnet will be able to reach their own default gateways.

While you could do this usingĀ several physical interfaces, the recommended way consists in using one physical interface and multiple virtual subinterfaces.

Configure router subinterfaces

configure terminal
interface gigabitEthernet 0/0.10
encapsulation dot1q $vlan
ip address $ip $netmask

An alternative to this method consists in using a Layer 3 switch (which, thanks to ASIC, would be more performant than a router which does everything in software), but this is out of scope for the CCENT.

Configure static routing

ip route $destination_network $destination_netmask $next_hop_ip_address | $outgoing_interface

To configure a default route (which is going to be used anytime an incoming packet does not match any entry in the router’s routing table):

ip route $isp_router_ip_address

Configure floating static routes

Floating static routes are nothing more than static routes with a manually set administrative distance. As such, they are very useful as a backup, for example as a backup of the default route.

ip route 1-255

Configure OSPF

router ospf 1
network $interface $wildcard area $area

network identifies the interfaces OSPF is going to send hello messages on (effectively, the interfaces on which you will form neighbour relationships) and will advertise that network to other routers.

So for example:

network area 0

is going to send hello messages and advertise the every network starting with 10.10.10. Where the wildcard is 255, the value in that octet will be ignored.

To enable OSPF on every interface, the command would be

network area 0

The more specific you get, the better, so something like the following is better than any of the previous commands:

network area 0

To stop OSPF from sending hello messages on an interface but still make it advertise that network, set that interface to passive with the passive-interface $interface command. For security reasons, it is recommended to set all interfaces to passive by default, and only manually enable the ones you want to send hello messages from:

passive-interface default

in OSPF configuration mode, and to manually disable passive mode on the specific interfaces with the no passive-interface command.

To check if OSPF is working, run

show ip ospf neighbor
show ip protocols

Followed by a

show ip route