Famciclovir works by inhibiting the replication of viral DNA. When converted to penciclovir, it interferes with the viral DNA polymerase enzyme, which is essential for the virus to reproduce. This process helps to reduce the severity and duration of the outbreak.