for example if you need to create the sub interface under f0/0
conf terminal#
interface fastEthernet0/0.1
the ip address of the interface and the vlan
interface fastEthernet0/0.2
i hope the answer is as simple as this.
Sub interface doesn't related with OSPF. You can create millions of sub-interfaces that may vary depending on router platforms.
Normally there is two occasion when we create sub-interface:1. For Inter VLAN Routing using Router on a Stick method where each VLAN requires1 sub-interface to act as a gateway for that VLAN clients.2. When you are using Frame Relay for WAN connections - where multiple PVC's are being terminated at single physical interface. Inside Frame Relay you can create Point-to-Point or Point-to-Multipoint sub-interface depending on design requirement.
creation of sub interfaces has nothing to do with OSPF configurations:
int fastEthernet0/0.1
encapsulation dot1Q (VLAN)
ip add x.x.x.x
also you have to configure switch port that connects to physical router interface as trunk mode to allow passing multiple vlans, and by the way this design is called router on stick.
if you need to enable ospf process on these sub interfaces you just have to type:
conf t
router os1
net x.x.x.x0.0.0.0 ar (Area number)
end