def generate_routes(ip_set, v4_only=False):
    """Generate route lines for vpn configuration."""
    lines = []
    for ip in ip_set.iter_cidrs():
        if ip.version == 4:
            # route network netmask gateway metric
            lines.append(f"route {ip.network} {ip.netmask} vpn_gateway default")
        elif ip.version == 6 and not v4_only:
            # route network/bits gateway metric
            lines.append(f"route-ipv6 {ip} default default")
    return lines